summaryrefslogtreecommitdiffhomepage
path: root/misc/benchmarks/plotbench/cpque_benchmark.cpp
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-03-30 17:59:08 +0200
committerTyge Løvset <[email protected]>2023-03-30 17:59:08 +0200
commita0a290645828c88597efce80f6b0f5a958cefa89 (patch)
tree53dc78071653b515a06a60baf4488a1b6d080b32 /misc/benchmarks/plotbench/cpque_benchmark.cpp
parent32df5677c9906661e91aad294e45a258e2eaab18 (diff)
downloadSTC-modified-a0a290645828c88597efce80f6b0f5a958cefa89.tar.gz
STC-modified-a0a290645828c88597efce80f6b0f5a958cefa89.zip
Added crand.h - Alternative API to crandom.h, which will be deprecated.
Diffstat (limited to 'misc/benchmarks/plotbench/cpque_benchmark.cpp')
-rw-r--r--misc/benchmarks/plotbench/cpque_benchmark.cpp32
1 files changed, 14 insertions, 18 deletions
diff --git a/misc/benchmarks/plotbench/cpque_benchmark.cpp b/misc/benchmarks/plotbench/cpque_benchmark.cpp
index a729c09f..da092b7f 100644
--- a/misc/benchmarks/plotbench/cpque_benchmark.cpp
+++ b/misc/benchmarks/plotbench/cpque_benchmark.cpp
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <time.h>
#define i_static
-#include <stc/crandom.h>
+#include <stc/crand.h>
#define i_val float
#define i_cmp -c_default_cmp
@@ -11,19 +11,17 @@
#include <queue>
static const uint32_t seed = 1234;
+static const int N = 10000000;
void std_test()
{
- stc64_t rng;
- int N = 10000000;
-
std::priority_queue<float, std::vector<float>, std::greater<float>> pq;
- rng = stc64_new(seed);
+ csrand(seed);
clock_t start = clock();
c_forrange (i, N)
- pq.push((float) stc64_randf(&rng)*100000);
+ pq.push((float) crandf()*100000.0);
- printf("Built priority queue: %f secs\n", (clock() - start) / (float) CLOCKS_PER_SEC);
+ printf("Built priority queue: %f secs\n", (float)(clock() - start)/(float)CLOCKS_PER_SEC);
printf("%g ", pq.top());
start = clock();
@@ -31,32 +29,30 @@ void std_test()
pq.pop();
}
- printf("\npopped PQ: %f secs\n\n", (clock() - start) / (float) CLOCKS_PER_SEC);
+ printf("\npopped PQ: %f secs\n\n", (float)(clock() - start)/(float)CLOCKS_PER_SEC);
}
void stc_test()
{
- stc64_t rng;
- int N = 10000000, M = 10;
+ int N = 10000000;
c_auto (cpque_f, pq)
{
- rng = stc64_new(seed);
+ csrand(seed);
clock_t start = clock();
- c_forrange (i, N)
- cpque_f_push(&pq, (float) stc64_randf(&rng)*100000);
+ c_forrange (i, N) {
+ cpque_f_push(&pq, (float) crandf()*100000);
+ }
- printf("Built priority queue: %f secs\n", (clock() - start) / (float) CLOCKS_PER_SEC);
+ printf("Built priority queue: %f secs\n", (float)(clock() - start)/(float)CLOCKS_PER_SEC);
printf("%g ", *cpque_f_top(&pq));
- c_forrange (i, M) {
+ start = clock();
+ c_forrange (i, N) {
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);
}
}