[ekg2-commit] ekg2: ekg_hash_benchmark.c (HEAD) [darkjames]
CVS commit
cvs w toxygen.net
Pon, 8 Paź 2007, 13:30:14 CEST
Module name: ekg2
Changes by: darkjames 2007-10-08 13:30:12
Modified files:
ekg_hash_benchmark.c
Log message:
idea of speeding up format_find()
Index: ekg_hash_benchmark.c
===================================================================
RCS file: /home/cvs/ekg2/contrib/ekg_hash_benchmark.c,v
diff -d -u -r1.5 -r1.6
--- ekg_hash_benchmark.c 8 May 2007 10:20:32 -0000 1.5
+++ ekg_hash_benchmark.c 8 Oct 2007 11:30:12 -0000 1.6
@@ -19,6 +19,7 @@
typedef struct list *list_t;
+int hashes[256];
void ekg_oom_handler() { printf("braklo pamieci\n"); exit(1); }
void *xmalloc(size_t size) { void *tmp = malloc(size); if (!tmp) ekg_oom_handler(); memset(tmp, 0, size); return tmp; }
@@ -87,6 +88,8 @@
f->name_hash = hash;
f->value = xstrdup(value);
+ hashes[hash & 0xff]++;
+
list_add_beginning(&formats, f);
return;
}
@@ -1269,6 +1272,18 @@
format_find(f->name);
}
}
+
+ {
+ int totalhash = 0;
+
+ for (i = 0; i < 0x100; i++)
+ totalhash += hashes[i];
+
+ printf("-- %d\n", totalhash);
+
+ for (i = 0; i < 0x100; i++)
+ printf("%d %.2f\n", hashes[i], (float) ( ((float) hashes[i] / (float) totalhash) * 100));
+ }
return 0;
}
Więcej informacji o liście dyskusyjnej ekg2-commit