diff options
author | Jan Huwald <jh@sotun.de> | 2012-05-07 20:01:51 (GMT) |
---|---|---|
committer | Jan Huwald <jh@sotun.de> | 2012-05-07 20:01:51 (GMT) |
commit | 420d2ef464d4a741028e132e662d5626806a41f5 (patch) | |
tree | 1aca6eb512e4ed0fb5f3c10c528cb998b6ffd695 /core/test_prioque_speed.cpp |
Diffstat (limited to 'core/test_prioque_speed.cpp')
-rw-r--r-- | core/test_prioque_speed.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/core/test_prioque_speed.cpp b/core/test_prioque_speed.cpp new file mode 100644 index 0000000..adb6d63 --- /dev/null +++ b/core/test_prioque_speed.cpp @@ -0,0 +1,38 @@ +#include <iostream> +#include <stdlib.h> + +#include "perftools.hpp" +#include "priority_queue.hpp" + +using namespace std; + +int main() { + // PQ is an open ended data structure -> alloc an arbitrary mem amount + PriorityQueue<double, int> *pq; + + Timer *timer = new Timer(); + int trans = 1000000; + int maxBase = 1024 * 1024; + void *mem = malloc(20 * 1024 * 1024); + + for (int i=0; i<trans; i++) { + drand48(); + } + print_throughput(timer->diff(), trans, (char*) "raw PRNG"); + + for (int base=1; base<=maxBase; base*=2) { + // setup queue + pq = new(mem) PriorityQueue<double, int>(); + for (int i=0; i<base; i++) pq->insert(drand48(),0); + + // test queue + timer = new Timer(); + for (int i=0; i<trans; i++) { + pq->insert(i, 0); + pq->removeMin(); + } + print_throughput2(timer->diff(), trans, base); + } + + return 0; +} |