summaryrefslogtreecommitdiffhomepage
path: root/misc/benchmarks/plotbench/cpque_benchmark.cpp
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-04-08 22:37:06 +0200
committerGitHub <[email protected]>2023-04-08 22:37:06 +0200
commit43120f2863a67db416ec3b379eb820e2704cafb7 (patch)
treef3b9917940f94c1582bc39ea6f56b735295ec861 /misc/benchmarks/plotbench/cpque_benchmark.cpp
parente8be14dfc894eeac859f0287d4d5b4f4745c0585 (diff)
parent6426ac05eb8c4dc1ab22aae2eb4139f9671981b7 (diff)
downloadSTC-modified-43120f2863a67db416ec3b379eb820e2704cafb7.tar.gz
STC-modified-43120f2863a67db416ec3b379eb820e2704cafb7.zip
Merge pull request #53 from tylov/dev42
Version 4.2 RC
Diffstat (limited to 'misc/benchmarks/plotbench/cpque_benchmark.cpp')
-rw-r--r--misc/benchmarks/plotbench/cpque_benchmark.cpp34
1 files changed, 15 insertions, 19 deletions
diff --git a/misc/benchmarks/plotbench/cpque_benchmark.cpp b/misc/benchmarks/plotbench/cpque_benchmark.cpp
index a729c09f..2d4c7a28 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 = 2500000;
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) {
- cpque_f_pop(&pq);
- }
start = clock();
- c_forrange (i, M, N)
+ c_forrange (i, N) {
cpque_f_pop(&pq);
+ }
+
printf("\npopped PQ: %f secs\n", (clock() - start) / (float) CLOCKS_PER_SEC);
}
}