54 static int profiling_prefilter_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_prefilter_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,
" %-32s %-15s %-15s %-15s %-15s %-15s %-15s %-15s %-15s %-15s\n",
"Prefilter",
100 "Ticks",
"Called",
"Max Ticks",
"Avg",
"Bytes",
"Called",
"Max Bytes",
"Avg Bytes",
102 fprintf(fp,
" -------------------------------- "
113 for (i = 0; i < (int)rules_ctx->
size; i++) {
115 if (d == NULL || d->
called== 0)
118 uint64_t ticks = d->
total;
121 avgticks = (double)(ticks / d->
called);
127 double ticks_per_byte = 0;
133 " %-32s %-15" PRIu64
" %-15" PRIu64
" %-15" PRIu64
" %-15.2f %-15" PRIu64
134 " %-15" PRIu64
" %-15" PRIu64
" %-15.2f %-15.2f\n",
151 gettimeofday(&tval, NULL);
154 if (profiling_prefilter_output_to_file == 1) {
155 SCLogDebug(
"file %s mode %s", profiling_file_name, profiling_file_mode);
157 fp = fopen(profiling_file_name, profiling_file_mode);
160 SCLogError(
"failed to open %s: %s", profiling_file_name, strerror(errno));
167 fprintf(fp,
" ----------------------------------------------"
168 "------------------------------------------------------"
169 "----------------------------\n");
170 fprintf(fp,
" Date: %" PRId32
"/%" PRId32
"/%04d -- "
171 "%02d:%02d:%02d\n", tms->tm_mon + 1, tms->tm_mday, tms->tm_year + 1900,
172 tms->tm_hour,tms->tm_min, tms->tm_sec);
181 SCLogPerf(
"Done dumping prefilter profiling data.");
192 uint64_t bytes, uint64_t bytes_called)
217 if (pthread_mutex_init(&ctx->
data_m, NULL) != 0) {
218 FatalError(
"Failed to initialize hash table mutex.");
228 if (ctx->
data != NULL)
230 pthread_mutex_destroy(&ctx->
data_m);
238 SCProfilingPrefilterDump(
de_ctx);
287 SCProfilingPrefilterThreadMerge(det_ctx->
de_ctx, det_ctx);
325 SCLogPerf(
"Registered %"PRIu32
" prefilter profiling counters.", size);