diff --git a/src/dedupe.c b/src/dedupe.c index 3e145668..76eb87e1 100644 --- a/src/dedupe.c +++ b/src/dedupe.c @@ -17,7 +17,7 @@ #include #include -#define DEDUPE_HASH_SLOTS 64 +#define DEDUPE_HASH_SLOTS 32 typedef struct dedupe_entry { struct dedupe_entry *next; int trigger_date; @@ -173,3 +173,27 @@ InitDedupeTable(void) DedupeTable[i] = NULL; } } + +void +get_dedupe_hash_stats(int *total, int *maxlen, double *avglen) +{ + int len; + int i; + DedupeEntry *e; + + *maxlen = 0; + *total = 0; + for (i=0; inext; + } + if (len > *maxlen) { + *maxlen = len; + } + } + *avglen = (double) *total / (double) DEDUPE_HASH_SLOTS; +} diff --git a/src/main.c b/src/main.c index 302f542d..6c10f554 100644 --- a/src/main.c +++ b/src/main.c @@ -66,9 +66,11 @@ exitfunc(void) fflush(stdout); fflush(stderr); get_var_hash_stats(&total, &maxlen, &avglen); - fprintf(stderr, " Var hash: total = %d; maxlen = %d; avglen = %.3f\n", total, maxlen, avglen); + fprintf(stderr, " Var hash: total = %d; maxlen = %d; avglen = %.3f\n", total, maxlen, avglen); get_userfunc_hash_stats(&total, &maxlen, &avglen); - fprintf(stderr, "Func hash: total = %d; maxlen = %d; avglen = %.3f\n", total, maxlen, avglen); + fprintf(stderr, " Func hash: total = %d; maxlen = %d; avglen = %.3f\n", total, maxlen, avglen); + get_dedupe_hash_stats(&total, &maxlen, &avglen); + fprintf(stderr, "Dedup hash: total = %d; maxlen = %d; avglen = %.3f\n", total, maxlen, avglen); UnsetAllUserFuncs(); print_expr_nodes_stats(); } @@ -158,6 +160,7 @@ int main(int argc, char *argv[]) ShouldCache = (Iterations > 1); while (Iterations--) { + PerIterationInit(); DoReminders(); if (DebugFlag & DB_DUMP_VARS) { @@ -197,7 +200,6 @@ int main(int argc, char *argv[]) } } if (Iterations) { - PerIterationInit(); DSEToday++; } } diff --git a/src/protos.h b/src/protos.h index 4fe57bcd..c28f027f 100644 --- a/src/protos.h +++ b/src/protos.h @@ -247,8 +247,11 @@ extern int _private_sub_overflow(int a, int b); void print_sysvar_tokens(void); void print_builtinfunc_tokens(void); void print_remind_tokens(void); + +/* Stats for -ds output */ void get_var_hash_stats(int *total, int *maxlen, double *avglen); void get_userfunc_hash_stats(int *total, int *maxlen, double *avglen); +void get_dedupe_hash_stats(int *total, int *maxlen, double *avglen); /* Dedupe code */ int ShouldDedupe(int trigger_date, int trigger_time, char const *body); diff --git a/tests/test.cmp b/tests/test.cmp index 75697408..a3019d0f 100644 --- a/tests/test.cmp +++ b/tests/test.cmp @@ -5837,8 +5837,9 @@ Barf DEBUG +s # Don't want Remind to queue reminders EXIT - Var hash: total = 141; maxlen = 4; avglen = 2.104 -Func hash: total = 15; maxlen = 2; avglen = 0.484 + Var hash: total = 141; maxlen = 4; avglen = 2.104 + Func hash: total = 15; maxlen = 2; avglen = 0.484 +Dedup hash: total = 0; maxlen = 0; avglen = 0.000 Expression nodes allocated: 128 Expression nodes high-water: 73 Expression nodes leaked: 0 @@ -13290,8 +13291,9 @@ Parsed expression: isany("foo", 1 + 1, 2:00 + 1, '2021-01-01' + 1, '2021-01-01@1 "f" + "oo" => "foo" isany("foo", 2, 02:01, 2021-01-02, 2021-01-01@14:01, "foo", ?) => 1 No reminders. - Var hash: total = 1; maxlen = 1; avglen = 0.015 -Func hash: total = 0; maxlen = 0; avglen = 0.000 + Var hash: total = 1; maxlen = 1; avglen = 0.015 + Func hash: total = 0; maxlen = 0; avglen = 0.000 +Dedup hash: total = 0; maxlen = 0; avglen = 0.000 Expression nodes allocated: 512 Expression nodes high-water: 499 Expression nodes leaked: 0