if (profiling_keyword_enabled == 0)
return;
+ const int nlists = DetectBufferTypeMaxId();
gettimeofday(&tval, NULL);
tms = SCLocalTime(tval.tv_sec, &local_tm);
/* global stats first */
DoDump(de_ctx->profile_keyword_ctx, fp, "total");
/* per buffer stats next, but only if there are stats to print */
- for (i = 0; i < DETECT_SM_LIST_MAX; i++) {
+ for (i = 0; i < nlists; i++) {
int j;
uint64_t checks = 0;
for (j = 0; j < DETECT_TBLSIZE; j++) {
checks += de_ctx->profile_keyword_ctx_per_list[i]->data[j].checks;
}
- if (checks)
- DoDump(de_ctx->profile_keyword_ctx_per_list[i], fp,
- DetectSigmatchListEnumToString(i));
+ if (checks) {
+ const char *name = NULL;
+ if (i < DETECT_SM_LIST_DYNAMIC_START) {
+ name = DetectSigmatchListEnumToString(i);
+ } else {
+ name = DetectBufferTypeGetNameById(i);
+ }
+
+ DoDump(de_ctx->profile_keyword_ctx_per_list[i], fp, name);
+ }
}
fprintf(fp,"\n");
p->ticks_no_match += ticks;
/* store per list (buffer type) as well */
- if (det_ctx->keyword_perf_list >= 0 && det_ctx->keyword_perf_list < DETECT_SM_LIST_MAX) {
+ if (det_ctx->keyword_perf_list >= 0) {// && det_ctx->keyword_perf_list < DETECT_SM_LIST_MAX) {
p = &det_ctx->keyword_perf_data_per_list[det_ctx->keyword_perf_list][id];
p->checks++;
p->matches += match;
SCProfilingKeywordDump(de_ctx);
DetroyCtx(de_ctx->profile_keyword_ctx);
+
+ const int nlists = DetectBufferTypeMaxId();
int i;
- for (i = 0; i < DETECT_SM_LIST_MAX; i++) {
+ for (i = 0; i < nlists; i++) {
DetroyCtx(de_ctx->profile_keyword_ctx_per_list[i]);
}
+ SCFree(de_ctx->profile_keyword_ctx_per_list);
}
}
det_ctx->keyword_perf_data = a;
}
+ const int nlists = DetectBufferTypeMaxId();
+ det_ctx->keyword_perf_data_per_list = SCCalloc(nlists, sizeof(SCProfileKeywordData *));
+ BUG_ON(det_ctx->keyword_perf_data_per_list == NULL);
+
int i;
- for (i = 0; i < DETECT_SM_LIST_MAX; i++) {
+ for (i = 0; i < nlists; i++) {
SCProfileKeywordData *b = SCMalloc(sizeof(SCProfileKeywordData) * DETECT_TBLSIZE);
if (b != NULL) {
memset(b, 0x00, sizeof(SCProfileKeywordData) * DETECT_TBLSIZE);
de_ctx->profile_keyword_ctx->data[i].max = det_ctx->keyword_perf_data[i].max;
}
+ const int nlists = DetectBufferTypeMaxId();
int j;
- for (j = 0; j < DETECT_SM_LIST_MAX; j++) {
+ for (j = 0; j < nlists; j++) {
for (i = 0; i < DETECT_TBLSIZE; i++) {
de_ctx->profile_keyword_ctx_per_list[j]->data[i].checks += det_ctx->keyword_perf_data_per_list[j][i].checks;
de_ctx->profile_keyword_ctx_per_list[j]->data[i].matches += det_ctx->keyword_perf_data_per_list[j][i].matches;
SCFree(det_ctx->keyword_perf_data);
det_ctx->keyword_perf_data = NULL;
+ const int nlists = DetectBufferTypeMaxId();
int i;
- for (i = 0; i < DETECT_SM_LIST_MAX; i++) {
+ for (i = 0; i < nlists; i++) {
SCFree(det_ctx->keyword_perf_data_per_list[i]);
det_ctx->keyword_perf_data_per_list[i] = NULL;
}
-
+ SCFree(det_ctx->keyword_perf_data_per_list);
}
/**
if (profiling_keyword_enabled == 0)
return;
+ const int nlists = DetectBufferTypeMaxId();
+
de_ctx->profile_keyword_ctx = SCProfilingKeywordInitCtx();
BUG_ON(de_ctx->profile_keyword_ctx == NULL);
BUG_ON(de_ctx->profile_keyword_ctx->data == NULL);
memset(de_ctx->profile_keyword_ctx->data, 0x00, sizeof(SCProfileKeywordData) * DETECT_TBLSIZE);
+ de_ctx->profile_keyword_ctx_per_list = SCCalloc(nlists, sizeof(SCProfileKeywordDetectCtx *));
+ BUG_ON(de_ctx->profile_keyword_ctx_per_list == NULL);
+
int i;
- for (i = 0; i < DETECT_SM_LIST_MAX; i++) {
+ for (i = 0; i < nlists; i++) {
de_ctx->profile_keyword_ctx_per_list[i] = SCProfilingKeywordInitCtx();
BUG_ON(de_ctx->profile_keyword_ctx_per_list[i] == NULL);
de_ctx->profile_keyword_ctx_per_list[i]->data = SCMalloc(sizeof(SCProfileKeywordData) * DETECT_TBLSIZE);