55 static int profiling_prefilter_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_prefilter_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,
" %-32s %-15s %-15s %-15s %-15s %-15s %-15s %-15s %-15s %-15s\n",
"Prefilter",
103 "Ticks",
"Called",
"Max Ticks",
"Avg",
"Bytes",
"Called",
"Max Bytes",
"Avg Bytes",
105 fprintf(fp,
" -------------------------------- "
116 for (i = 0; i < (int)rules_ctx->
size; i++) {
118 if (d == NULL || d->
called== 0)
121 uint64_t ticks = d->
total;
124 avgticks = (double)(ticks / d->
called);
130 double ticks_per_byte = 0;
136 " %-32s %-15" PRIu64
" %-15" PRIu64
" %-15" PRIu64
" %-15.2f %-15" PRIu64
137 " %-15" PRIu64
" %-15" PRIu64
" %-15.2f %-15.2f\n",
154 gettimeofday(&tval, NULL);
157 if (profiling_prefilter_output_to_file == 1) {
158 SCLogDebug(
"file %s mode %s", profiling_file_name, profiling_file_mode);
160 fp = fopen(profiling_file_name, profiling_file_mode);
163 SCLogError(
"failed to open %s: %s", profiling_file_name, strerror(errno));
170 fprintf(fp,
" ----------------------------------------------"
171 "------------------------------------------------------"
172 "----------------------------\n");
173 fprintf(fp,
" Date: %" PRId32
"/%" PRId32
"/%04d -- "
174 "%02d:%02d:%02d\n", tms->tm_mon + 1, tms->tm_mday, tms->tm_year + 1900,
175 tms->tm_hour,tms->tm_min, tms->tm_sec);
184 SCLogPerf(
"Done dumping prefilter profiling data.");
195 uint64_t bytes, uint64_t bytes_called)
218 if (pthread_mutex_init(&
ctx->data_m, NULL) != 0) {
219 FatalError(
"Failed to initialize hash table mutex.");
229 if (
ctx->data != NULL)
231 pthread_mutex_destroy(&
ctx->data_m);
239 SCProfilingPrefilterDump(
de_ctx);
287 SCProfilingPrefilterThreadMerge(det_ctx->
de_ctx, det_ctx);
324 SCLogPerf(
"Registered %"PRIu32
" prefilter profiling counters.", size);