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) {
73 snprintf(profiling_file_name,
sizeof(profiling_file_name),
"%s/%s",
78 profiling_file_mode =
"a";
80 profiling_file_mode =
"w";
83 profiling_keywords_output_to_file = 1;
92 fprintf(fp,
" ----------------------------------------------"
93 "------------------------------------------------------"
94 "----------------------------\n");
95 fprintf(fp,
" Stats for: %s\n", name);
96 fprintf(fp,
" ----------------------------------------------"
97 "------------------------------------------------------"
98 "----------------------------\n");
99 fprintf(fp,
" %-16s %-15s %-15s %-15s %-15s %-15s %-15s %-15s\n",
"Keyword",
"Ticks",
"Checks",
"Matches",
"Max Ticks",
"Avg",
"Avg Match",
"Avg No Match");
100 fprintf(fp,
" ---------------- "
111 if (d == NULL || d->
checks == 0)
116 double avgticks_match = 0;
117 double avgticks_no_match = 0;
119 avgticks = (double)(ticks / d->
checks);
128 " %-16s %-15"PRIu64
" %-15"PRIu64
" %-15"PRIu64
" %-15"PRIu64
" %-15.2f %-15.2f %-15.2f\n",
153 gettimeofday(&tval, NULL);
156 if (profiling_keywords_output_to_file == 1) {
157 SCLogDebug(
"file %s mode %s", profiling_file_name, profiling_file_mode);
159 fp = fopen(profiling_file_name, profiling_file_mode);
162 SCLogError(
"failed to open %s: %s", profiling_file_name, strerror(errno));
169 fprintf(fp,
" ----------------------------------------------"
170 "------------------------------------------------------"
171 "----------------------------\n");
172 fprintf(fp,
" Date: %" PRId32
"/%" PRId32
"/%04d -- "
173 "%02d:%02d:%02d\n", tms->tm_mon + 1, tms->tm_mday, tms->tm_year + 1900,
174 tms->tm_hour,tms->tm_min, tms->tm_sec);
179 for (i = 0; i < nlists; i++) {
187 const char *name = NULL;
202 SCLogPerf(
"Done dumping keyword profiling data.");
248 if (pthread_mutex_init(&ctx->
data_m, NULL) != 0) {
249 FatalError(
"Failed to initialize hash table mutex.");
259 if (ctx->
data != NULL)
261 pthread_mutex_destroy(&ctx->
data_m);
269 SCProfilingKeywordDump(
de_ctx);
275 for (i = 0; i < nlists; i++) {
298 for (i = 0; i < nlists; i++) {
327 for (j = 0; j < nlists; j++) {
345 SCProfilingKeywordThreadMerge(det_ctx->
de_ctx, det_ctx);
353 for (i = 0; i < nlists; i++) {
384 for (i = 0; i < nlists; i++) {