blob: adb6d6332ec3f026432eb7ac5d5998af4c6a311d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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;
}
|