[前][次][番号順一覧][スレッド一覧]

ruby-changes:42364

From: nobu <ko1@a...>
Date: Wed, 30 Mar 2016 22:02:22 +0900 (JST)
Subject: [ruby-changes:42364] nobu:r54438 (trunk): st.c: fix collision statistics [ci skip]

nobu	2016-03-30 22:02:16 +0900 (Wed, 30 Mar 2016)

  New Revision: 54438

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54438

  Log:
    st.c: fix collision statistics [ci skip]
    
    * st.c (stat_col): get rid of NaN.
    
    * st.c (collision_check): define before used.

  Modified files:
    trunk/st.c
Index: st.c
===================================================================
--- st.c	(revision 54437)
+++ st.c	(revision 54438)
@@ -185,7 +185,9 @@ static void https://github.com/ruby/ruby/blob/trunk/st.c#L185
 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_typ https://github.com/ruby/ruby/blob/trunk/st.c#L340
 }
 #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, https://github.com/ruby/ruby/blob/trunk/st.c#L382
     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_ https://github.com/ruby/ruby/blob/trunk/st.c#L438
     }
 }
 
-#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)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]