summaryrefslogtreecommitdiff
path: root/core/test_prioque_speed.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/test_prioque_speed.cpp')
-rw-r--r--core/test_prioque_speed.cpp38
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;
+}
contact: Jan Huwald // Impressum