55static int profiling_keywords_output_to_file = 0;
58static char profiling_file_name[PATH_MAX];
59static 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++) {
SCConfNode * SCConfGetNode(const char *name)
Get a SCConfNode by name.
int SCConfNodeChildValueIsTrue(const SCConfNode *node, const char *key)
Test if a configuration node has a true value.
int SCConfValIsTrue(const char *val)
Check if a value is true.
const char * SCConfNodeLookupChildValue(const SCConfNode *node, const char *name)
Lookup the value of a child configuration node by name.
const char * DetectEngineBufferTypeGetNameById(const DetectEngineCtx *de_ctx, const int id)
const char * DetectSigmatchListEnumToString(enum DetectSigmatchListEnum type)
SigTableElmt * sigmatch_table
@ DETECT_SM_LIST_DYNAMIC_START
main detection engine ctx
struct SCProfileKeywordDetectCtx_ * profile_keyword_ctx
struct SCProfileKeywordDetectCtx_ ** profile_keyword_ctx_per_list
struct SCProfileKeywordData_ ** keyword_perf_data_per_list
struct SCProfileKeywordData_ * keyword_perf_data
SCProfileKeywordData * data
size_t strlcpy(char *dst, const char *src, size_t siz)
const char * SCConfigGetLogDirectory(void)
#define SCLogError(...)
Macro used to log ERROR messages.
int PathIsAbsolute(const char *path)
Check if a path is absolute.
void SCProfilingKeywordsGlobalInit(void)
void SCProfilingKeywordThreadCleanup(DetectEngineThreadCtx *det_ctx)
struct SCProfileKeywordData_ SCProfileKeywordData
void SCProfilingKeywordDestroyCtx(DetectEngineCtx *de_ctx)
void SCProfilingKeywordThreadSetup(SCProfileKeywordDetectCtx *ctx, DetectEngineThreadCtx *det_ctx)
void SCProfilingKeywordUpdateCounter(DetectEngineThreadCtx *det_ctx, int id, uint64_t ticks, int match)
Update a rule counter.
thread_local int profiling_keyword_entered
int profiling_keyword_enabled
struct SCProfileKeywordDetectCtx_ SCProfileKeywordDetectCtx
void SCProfilingKeywordInitCounters(DetectEngineCtx *de_ctx)
Register the keyword profiling counters.
struct tm * SCLocalTime(time_t timep, struct tm *result)