@@ -126,85 +126,6 @@ static void perf_hashmap(unsigned int method, unsigned int rounds)
126126 }
127127}
128128
129- struct hash_entry
130- {
131- struct hash_entry * next ;
132- char key [FLEX_ARRAY ];
133- };
134-
135- /*
136- * Test performance of hash.[ch]
137- * Usage: time echo "perfhash method rounds" | test-hashmap
138- */
139- static void perf_hash (unsigned int method , unsigned int rounds )
140- {
141- struct hash_table map ;
142- char buf [16 ];
143- struct hash_entry * * entries , * * res , * entry ;
144- unsigned int * hashes ;
145- unsigned int i , j ;
146-
147- entries = malloc (TEST_SIZE * sizeof (struct hash_entry * ));
148- hashes = malloc (TEST_SIZE * sizeof (int ));
149- for (i = 0 ; i < TEST_SIZE ; i ++ ) {
150- snprintf (buf , sizeof (buf ), "%i" , i );
151- entries [i ] = malloc (sizeof (struct hash_entry ) + strlen (buf ) + 1 );
152- strcpy (entries [i ]-> key , buf );
153- hashes [i ] = hash (method , i , entries [i ]-> key );
154- }
155-
156- if (method & TEST_ADD ) {
157- /* test adding to the map */
158- for (j = 0 ; j < rounds ; j ++ ) {
159- init_hash (& map );
160-
161- /* add entries */
162- for (i = 0 ; i < TEST_SIZE ; i ++ ) {
163- res = (struct hash_entry * * ) insert_hash (
164- hashes [i ], entries [i ], & map );
165- if (res ) {
166- entries [i ]-> next = * res ;
167- * res = entries [i ];
168- } else {
169- entries [i ]-> next = NULL ;
170- }
171- }
172-
173- free_hash (& map );
174- }
175- } else {
176- /* test map lookups */
177- init_hash (& map );
178-
179- /* fill the map (sparsely if specified) */
180- j = (method & TEST_SPARSE ) ? TEST_SIZE / 10 : TEST_SIZE ;
181- for (i = 0 ; i < j ; i ++ ) {
182- res = (struct hash_entry * * ) insert_hash (hashes [i ],
183- entries [i ], & map );
184- if (res ) {
185- entries [i ]-> next = * res ;
186- * res = entries [i ];
187- } else {
188- entries [i ]-> next = NULL ;
189- }
190- }
191-
192- for (j = 0 ; j < rounds ; j ++ ) {
193- for (i = 0 ; i < TEST_SIZE ; i ++ ) {
194- entry = lookup_hash (hashes [i ], & map );
195- while (entry ) {
196- if (!strcmp (entries [i ]-> key , entry -> key ))
197- break ;
198- entry = entry -> next ;
199- }
200- }
201- }
202-
203- free_hash (& map );
204-
205- }
206- }
207-
208129#define DELIM " \t\r\n"
209130
210131/*
@@ -218,7 +139,6 @@ static void perf_hash(unsigned int method, unsigned int rounds)
218139 * size -> tablesize numentries
219140 *
220141 * perfhashmap method rounds -> test hashmap.[ch] performance
221- * perfhash method rounds -> test hash.[ch] performance
222142 */
223143int main (int argc , char * argv [])
224144{
@@ -324,10 +244,6 @@ int main(int argc, char *argv[])
324244
325245 perf_hashmap (atoi (p1 ), atoi (p2 ));
326246
327- } else if (!strcmp ("perfhash" , cmd ) && l1 && l2 ) {
328-
329- perf_hash (atoi (p1 ), atoi (p2 ));
330-
331247 } else {
332248
333249 printf ("Unknown command %s\n" , cmd );
0 commit comments