43 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
63 static int profiling_keywords_output_to_file = 0;
66 static char profiling_file_name[PATH_MAX];
67 static const char *profiling_file_mode =
"a";
78 if (filename != NULL) {
82 snprintf(profiling_file_name,
sizeof(profiling_file_name),
"%s/%s",
87 profiling_file_mode =
"a";
89 profiling_file_mode =
"w";
92 profiling_keywords_output_to_file = 1;
101 fprintf(fp,
" ----------------------------------------------"
102 "------------------------------------------------------"
103 "----------------------------\n");
104 fprintf(fp,
" Stats for: %s\n", name);
105 fprintf(fp,
" ----------------------------------------------"
106 "------------------------------------------------------"
107 "----------------------------\n");
108 fprintf(fp,
" %-16s %-15s %-15s %-15s %-15s %-15s %-15s %-15s\n",
"Keyword",
"Ticks",
"Checks",
"Matches",
"Max Ticks",
"Avg",
"Avg Match",
"Avg No Match");
109 fprintf(fp,
" ---------------- "
120 if (d == NULL || d->
checks == 0)
125 double avgticks_match = 0;
126 double avgticks_no_match = 0;
128 avgticks = (ticks / d->
checks);
137 " %-16s %-15"PRIu64
" %-15"PRIu64
" %-15"PRIu64
" %-15"PRIu64
" %-15.2f %-15.2f %-15.2f\n",
162 gettimeofday(&tval, NULL);
165 if (profiling_keywords_output_to_file == 1) {
166 SCLogDebug(
"file %s mode %s", profiling_file_name, profiling_file_mode);
168 fp = fopen(profiling_file_name, profiling_file_mode);
179 fprintf(fp,
" ----------------------------------------------"
180 "------------------------------------------------------"
181 "----------------------------\n");
182 fprintf(fp,
" Date: %" PRId32
"/%" PRId32
"/%04d -- "
183 "%02d:%02d:%02d\n", tms->tm_mon + 1, tms->tm_mday, tms->tm_year + 1900,
184 tms->tm_hour,tms->tm_min, tms->tm_sec);
189 for (i = 0; i < nlists; i++) {
197 const char *name = NULL;
212 SCLogPerf(
"Done dumping keyword profiling data.");
258 if (pthread_mutex_init(&ctx->
data_m, NULL) != 0) {
260 "Failed to initialize hash table mutex.");
270 if (ctx->
data != NULL)
272 pthread_mutex_destroy(&ctx->
data_m);
280 SCProfilingKeywordDump(
de_ctx);
286 for (i = 0; i < nlists; i++) {
309 for (i = 0; i < nlists; i++) {
338 for (j = 0; j < nlists; j++) {
356 SCProfilingKeywordThreadMerge(det_ctx->
de_ctx, det_ctx);
364 for (i = 0; i < nlists; i++) {
395 for (i = 0; i < nlists; i++) {