X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=common%2Ftst-trie.c;h=df9e1d27bc23de2d33c4493f014adbcb7a640959;hb=8b037ff01fb49d7de7776c8be6e69d28739128d5;hp=c9e16dc4480e272436ba2ce40f165329d8a9c3dd;hpb=520b2f3bb198bfbb88b90b058ef610f0a9b980c6;p=apps%2Fpfixtools.git diff --git a/common/tst-trie.c b/common/tst-trie.c index c9e16dc..df9e1d2 100644 --- a/common/tst-trie.c +++ b/common/tst-trie.c @@ -33,6 +33,8 @@ * Copyright © 2008 Florent Bruneau */ +#include +#include #include "common.h" #include "str.h" #include "trie.h" @@ -128,7 +130,20 @@ int main(int argc, char *argv[]) */ if (argc > 1) { trie = create_trie_from_file(argv[1]); - trie_inspect(trie, true); + trie_inspect(trie, false); + if (argc > 2) { + const uint32_t how_many = 8 * 1000 * 1000; + struct timeval start, end; + double diff; + + gettimeofday(&start, NULL); + for (uint32_t i = 0 ; i < how_many ; ++i) { + trie_lookup(trie, argv[2]); + } + gettimeofday(&end, NULL); + diff = (end.tv_sec - start.tv_sec) + (double)(end.tv_usec - start.tv_usec) / 10e6; + printf("%u lookups per second\n", (int)(how_many / diff)); + } trie_delete(&trie); } return 0;