54 static int profiling_keywords_output_to_file = 0;
57 static char profiling_file_name[PATH_MAX];
58 static const char *profiling_file_mode =
"a";
69 if (filename != NULL) {
71 strlcpy(profiling_file_name, filename,
sizeof(profiling_file_name));
74 snprintf(profiling_file_name,
sizeof(profiling_file_name),
"%s/%s", log_dir,
80 profiling_file_mode =
"a";
82 profiling_file_mode =
"w";
85 profiling_keywords_output_to_file = 1;
94 fprintf(fp,
" ----------------------------------------------"
95 "------------------------------------------------------"
96 "----------------------------\n");
97 fprintf(fp,
" Stats for: %s\n",
name);
98 fprintf(fp,
" ----------------------------------------------"
99 "------------------------------------------------------"
100 "----------------------------\n");
101 fprintf(fp,
" %-16s %-15s %-15s %-15s %-15s %-15s %-15s %-15s\n",
"Keyword",
"Ticks",
"Checks",
"Matches",
"Max Ticks",
"Avg",
"Avg Match",
"Avg No Match");
102 fprintf(fp,
" ---------------- "
113 if (d == NULL || d->
checks == 0)
118 double avgticks_match = 0;
119 double avgticks_no_match = 0;
121 avgticks = (double)(ticks / d->
checks);
130 " %-16s %-15"PRIu64
" %-15"PRIu64
" %-15"PRIu64
" %-15"PRIu64
" %-15.2f %-15.2f %-15.2f\n",
155 gettimeofday(&tval, NULL);
158 if (profiling_keywords_output_to_file == 1) {
159 SCLogDebug(
"file %s mode %s", profiling_file_name, profiling_file_mode);
161 fp = fopen(profiling_file_name, profiling_file_mode);
164 SCLogError(
"failed to open %s: %s", profiling_file_name, strerror(errno));
171 fprintf(fp,
" ----------------------------------------------"
172 "------------------------------------------------------"
173 "----------------------------\n");
174 fprintf(fp,
" Date: %" PRId32
"/%" PRId32
"/%04d -- "
175 "%02d:%02d:%02d\n", tms->tm_mon + 1, tms->tm_mday, tms->tm_year + 1900,
176 tms->tm_hour,tms->tm_min, tms->tm_sec);
181 for (i = 0; i < nlists; i++) {
189 const char *
name = NULL;
204 SCLogPerf(
"Done dumping keyword profiling data.");
225 p->ticks_match += ticks;
227 p->ticks_no_match += ticks;
237 p->ticks_match += ticks;
239 p->ticks_no_match += ticks;
249 if (pthread_mutex_init(&
ctx->data_m, NULL) != 0) {
250 FatalError(
"Failed to initialize hash table mutex.");
260 if (
ctx->data != NULL)
262 pthread_mutex_destroy(&
ctx->data_m);
270 SCProfilingKeywordDump(
de_ctx);
276 for (i = 0; i < nlists; i++) {
298 for (i = 0; i < nlists; i++) {
325 for (j = 0; j < nlists; j++) {
343 SCProfilingKeywordThreadMerge(det_ctx->
de_ctx, det_ctx);
351 for (i = 0; i < nlists; i++) {
381 for (i = 0; i < nlists; i++) {