summaryrefslogtreecommitdiffhomepage
path: root/benchmarks/plotbench/cpque_benchmark.cpp
diff options
context:
space:
mode:
authorTyge Lovset <[email protected]>2022-12-20 23:31:51 +0100
committerTyge Lovset <[email protected]>2022-12-20 23:31:51 +0100
commit5f57d597cd27aef55adbcb3b452973b0c6e33667 (patch)
treedfd59c2fd0e36a6ef37912a9d0cc5a65970f1524 /benchmarks/plotbench/cpque_benchmark.cpp
parent1763be8c8cbbc0896477fcf924edd4180d1345a9 (diff)
downloadSTC-modified-5f57d597cd27aef55adbcb3b452973b0c6e33667.tar.gz
STC-modified-5f57d597cd27aef55adbcb3b452973b0c6e33667.zip
Restructured folders: examples, benchmarks, tests into misc folder.
Diffstat (limited to 'benchmarks/plotbench/cpque_benchmark.cpp')
-rw-r--r--benchmarks/plotbench/cpque_benchmark.cpp71
1 files changed, 0 insertions, 71 deletions
diff --git a/benchmarks/plotbench/cpque_benchmark.cpp b/benchmarks/plotbench/cpque_benchmark.cpp
deleted file mode 100644
index a729c09f..00000000
--- a/benchmarks/plotbench/cpque_benchmark.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-#include <stdio.h>
-#include <time.h>
-#define i_static
-#include <stc/crandom.h>
-
-#define i_val float
-#define i_cmp -c_default_cmp
-#define i_tag f
-#include <stc/cpque.h>
-
-#include <queue>
-
-static const uint32_t seed = 1234;
-
-void std_test()
-{
- stc64_t rng;
- int N = 10000000;
-
- std::priority_queue<float, std::vector<float>, std::greater<float>> pq;
- rng = stc64_new(seed);
- clock_t start = clock();
- c_forrange (i, N)
- pq.push((float) stc64_randf(&rng)*100000);
-
- printf("Built priority queue: %f secs\n", (clock() - start) / (float) CLOCKS_PER_SEC);
- printf("%g ", pq.top());
-
- start = clock();
- c_forrange (i, N) {
- pq.pop();
- }
-
- printf("\npopped PQ: %f secs\n\n", (clock() - start) / (float) CLOCKS_PER_SEC);
-}
-
-
-void stc_test()
-{
- stc64_t rng;
- int N = 10000000, M = 10;
-
- c_auto (cpque_f, pq)
- {
- rng = stc64_new(seed);
- clock_t start = clock();
- c_forrange (i, N)
- cpque_f_push(&pq, (float) stc64_randf(&rng)*100000);
-
- printf("Built priority queue: %f secs\n", (clock() - start) / (float) CLOCKS_PER_SEC);
- printf("%g ", *cpque_f_top(&pq));
-
- c_forrange (i, M) {
- cpque_f_pop(&pq);
- }
-
- start = clock();
- c_forrange (i, M, N)
- cpque_f_pop(&pq);
- printf("\npopped PQ: %f secs\n", (clock() - start) / (float) CLOCKS_PER_SEC);
- }
-}
-
-
-int main()
-{
- puts("STD P.QUEUE:");
- std_test();
- puts("\nSTC P.QUEUE:");
- stc_test();
-}