diff options
| author | Tyge Løvset <[email protected]> | 2021-11-06 23:14:20 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2021-11-06 23:14:20 +0100 |
| commit | 52e35a16e81181aea361a8257d5d447b599a00ab (patch) | |
| tree | ba12e93eb92b7cba79ef0d6b6a556a39535d695b /benchmarks/plotbench/cpque_benchmark.cpp | |
| parent | 38935b1d85da5be067b5cf0c00dc02d8cb231f9e (diff) | |
| download | STC-modified-52e35a16e81181aea361a8257d5d447b599a00ab.tar.gz STC-modified-52e35a16e81181aea361a8257d5d447b599a00ab.zip | |
Updated shootout_hashmaps.cpp. Cleanup/renamed benchmark folders.
Diffstat (limited to 'benchmarks/plotbench/cpque_benchmark.cpp')
| -rw-r--r-- | benchmarks/plotbench/cpque_benchmark.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/benchmarks/plotbench/cpque_benchmark.cpp b/benchmarks/plotbench/cpque_benchmark.cpp new file mode 100644 index 00000000..19a9c701 --- /dev/null +++ b/benchmarks/plotbench/cpque_benchmark.cpp @@ -0,0 +1,48 @@ +#include <stdio.h>
+#include <time.h>
+#include <stc/crandom.h>
+
+#define i_val float
+#define i_cmp -c_default_compare
+#define i_tag f
+#include <stc/cpque.h>
+
+int main()
+{
+ uint32_t seed = time(NULL);
+ stc64_t rng;
+ int N = 10000000, M = 10;
+
+ cpque_f pq = cpque_f_init();
+
+ rng = stc64_init(seed);
+ clock_t start = clock();
+ c_forrange (i, int, N)
+ cpque_f_push_back(&pq, (float) stc64_randf(&rng)*100000);
+
+ cpque_f_make_heap(&pq);
+ printf("Built priority queue: %f secs\n", (clock() - start) / (float) CLOCKS_PER_SEC);
+
+ c_forrange (i, int, M) {
+ printf("%g ", *cpque_f_top(&pq));
+ cpque_f_pop(&pq);
+ }
+
+ start = clock();
+ c_forrange (i, int, M, N)
+ cpque_f_pop(&pq);
+ printf("\n\npopped PQ: %f secs\n", (clock() - start) / (float) CLOCKS_PER_SEC);
+
+ start = clock();
+ c_forrange (i, int, N)
+ cpque_f_push(&pq, (float) stc64_randf(&rng)*100000);
+ printf("pushed PQ: %f secs\n", (clock() - start) / (float) CLOCKS_PER_SEC);
+
+ c_forrange (i, int, M) {
+ printf("%g ", *cpque_f_top(&pq));
+ cpque_f_pop(&pq);
+ }
+ puts("");
+
+ cpque_f_del(&pq);
+}
|
