55 static int profiling_keywords_output_to_file = 0;
58 static char profiling_file_name[PATH_MAX];
59 static const char *profiling_file_mode =
"a";
70 if (filename != NULL) {
72 strlcpy(profiling_file_name, filename,
sizeof(profiling_file_name));
75 snprintf(profiling_file_name,
sizeof(profiling_file_name),
"%s/%s", log_dir,
81 profiling_file_mode =
"a";
83 profiling_file_mode =
"w";
86 profiling_keywords_output_to_file = 1;
95 fprintf(fp,
" ----------------------------------------------"
96 "------------------------------------------------------"
97 "----------------------------\n");
98 fprintf(fp,
" Stats for: %s\n", name);
99 fprintf(fp,
" ----------------------------------------------"
100 "------------------------------------------------------"
101 "----------------------------\n");
102 fprintf(fp,
" %-16s %-15s %-15s %-15s %-15s %-15s %-15s %-15s\n",
"Keyword",
"Ticks",
"Checks",
"Matches",
"Max Ticks",
"Avg",
"Avg Match",
"Avg No Match");
103 fprintf(fp,
" ---------------- "
114 if (d == NULL || d->
checks == 0)
119 double avgticks_match = 0;
120 double avgticks_no_match = 0;
122 avgticks = (double)(ticks / d->
checks);
131 " %-16s %-15"PRIu64
" %-15"PRIu64
" %-15"PRIu64
" %-15"PRIu64
" %-15.2f %-15.2f %-15.2f\n",
156 gettimeofday(&tval, NULL);
159 if (profiling_keywords_output_to_file == 1) {
160 SCLogDebug(
"file %s mode %s", profiling_file_name, profiling_file_mode);
162 fp = fopen(profiling_file_name, profiling_file_mode);
165 SCLogError(
"failed to open %s: %s", profiling_file_name, strerror(errno));
172 fprintf(fp,
" ----------------------------------------------"
173 "------------------------------------------------------"
174 "----------------------------\n");
175 fprintf(fp,
" Date: %" PRId32
"/%" PRId32
"/%04d -- "
176 "%02d:%02d:%02d\n", tms->tm_mon + 1, tms->tm_mday, tms->tm_year + 1900,
177 tms->tm_hour,tms->tm_min, tms->tm_sec);
182 for (i = 0; i < nlists; i++) {
190 const char *name = NULL;
205 SCLogPerf(
"Done dumping keyword profiling data.");
250 if (pthread_mutex_init(&
ctx->data_m, NULL) != 0) {
251 FatalError(
"Failed to initialize hash table mutex.");
261 if (
ctx->data != NULL)
263 pthread_mutex_destroy(&
ctx->data_m);
271 SCProfilingKeywordDump(
de_ctx);
277 for (i = 0; i < nlists; i++) {
299 for (i = 0; i < nlists; i++) {
326 for (j = 0; j < nlists; j++) {
344 SCProfilingKeywordThreadMerge(det_ctx->
de_ctx, det_ctx);
352 for (i = 0; i < nlists; i++) {
382 for (i = 0; i < nlists; i++) {