From f2fbcf2c18abc6704ce3dcf7bf15f5c32c3d8618 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 30 Mar 2016 13:02:16 +0000 Subject: st.c: fix collision statistics [ci skip] * st.c (stat_col): get rid of NaN. * st.c (collision_check): define before used. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54438 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- st.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'st.c') diff --git a/st.c b/st.c index 086ae4d825..9672c2e6fd 100644 --- a/st.c +++ b/st.c @@ -185,7 +185,9 @@ static void stat_col(void) { char fname[10+sizeof(long)*3]; - FILE *f = fopen((snprintf(fname, sizeof(fname), "/tmp/col%ld", (long)getpid()), fname), "w"); + FILE *f; + if (!collision.total) return; + f = fopen((snprintf(fname, sizeof(fname), "/tmp/col%ld", (long)getpid()), fname), "w"); fprintf(f, "collision: %d / %d (%6.2f)\n", collision.all, collision.total, ((double)collision.all / (collision.total)) * 100); fprintf(f, "num: %d, str: %d, strcase: %d\n", collision.num, collision.str, collision.strcase); @@ -338,6 +340,7 @@ count_collision(const struct st_hash_type *type) } #define COLLISION (collision_check ? count_collision(table->type) : (void)0) #define FOUND_ENTRY (collision_check ? collision.total++ : (void)0) +#define collision_check 0 #else #define COLLISION #define FOUND_ENTRY @@ -379,8 +382,6 @@ find_packed_index(const st_table *table, st_index_t hash_val, st_data_t key) return find_packed_index_from(table, hash_val, key, 0); } -#define collision_check 0 - int st_lookup(st_table *table, register st_data_t key, st_data_t *value) { @@ -437,9 +438,6 @@ st_get_key(st_table *table, register st_data_t key, st_data_t *result) } } -#undef collision_check -#define collision_check 1 - static inline st_table_entry * new_entry(st_table * table, st_data_t key, st_data_t value, st_index_t hash_val, register st_index_t bin_pos) -- cgit v1.2.3