diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-30 13:02:16 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-30 13:02:16 +0000 |
commit | 828270af133a07cdef1ebd1d4db4c8b23e31eb52 (patch) | |
tree | 76622d3e2e02b6aa04c0df19737d1d31f971ba03 /st.c | |
parent | 2f6821a7c4e7a52ddc6476ab3fbccf1880be5935 (diff) | |
download | ruby-828270af133a07cdef1ebd1d4db4c8b23e31eb52.tar.gz |
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
Diffstat (limited to 'st.c')
-rw-r--r-- | st.c | 10 |
1 files changed, 4 insertions, 6 deletions
@@ -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) |