summaryrefslogtreecommitdiffhomepage
path: root/misc/benchmarks/plotbench/cvec_benchmark.cpp
diff options
context:
space:
mode:
authortylov <[email protected]>2023-07-24 22:57:44 +0200
committertylov <[email protected]>2023-07-24 22:57:44 +0200
commit78ba677b59a8cecd69f733fca1a37ad01b38320f (patch)
tree7a045c9c60ff74f6b04c10ce05921a3b3782c499 /misc/benchmarks/plotbench/cvec_benchmark.cpp
parentf1f0c01e798eb3217e62a43de660723173984547 (diff)
downloadSTC-modified-78ba677b59a8cecd69f733fca1a37ad01b38320f.tar.gz
STC-modified-78ba677b59a8cecd69f733fca1a37ad01b38320f.zip
Updated and fixed benchmarks and performance graphs.
Diffstat (limited to 'misc/benchmarks/plotbench/cvec_benchmark.cpp')
-rw-r--r--misc/benchmarks/plotbench/cvec_benchmark.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/misc/benchmarks/plotbench/cvec_benchmark.cpp b/misc/benchmarks/plotbench/cvec_benchmark.cpp
index 45b9cf93..fb10653a 100644
--- a/misc/benchmarks/plotbench/cvec_benchmark.cpp
+++ b/misc/benchmarks/plotbench/cvec_benchmark.cpp
@@ -9,10 +9,10 @@
#endif
enum {INSERT, ERASE, FIND, ITER, DESTRUCT, N_TESTS};
-const char* operations[] = {"insert", "erase", "find", "iter", "destruct"};
+const char* operations[] = {"insert", "erase", "access", "iter", "destruct"};
typedef struct { time_t t1, t2; uint64_t sum; float fac; } Range;
typedef struct { const char* name; Range test[N_TESTS]; } Sample;
-enum {SAMPLES = 2, N = 40000000, S = 0x3ffc, R = 4};
+enum {SAMPLES = 2, N = 60000000, R = 4};
uint64_t seed = 1, mask1 = 0xfffffff, mask2 = 0xffff;
static float secs(Range s) { return (float)(s.t2 - s.t1) / CLOCKS_PER_SEC; }
@@ -42,14 +42,12 @@ Sample test_std_vector() {
c_forrange (N) con.push_back(crand() & mask2);
s.test[FIND].t1 = clock();
size_t sum = 0;
- //container::iterator it;
- // Iteration - not inherent find - skipping
- //c_forrange (S) if ((it = std::find(con.begin(), con.end(), crand() & mask2)) != con.end()) sum += *it;
+ c_forrange (R) c_forrange (i, N) sum += con[i];
s.test[FIND].t2 = clock();
s.test[FIND].sum = sum;
s.test[ITER].t1 = clock();
sum = 0;
- c_forrange (R) c_forrange (i, N) sum += con[i];
+ c_forrange (R) for (const auto i: con) sum += i;
s.test[ITER].t2 = clock();
s.test[ITER].sum = sum;
s.test[DESTRUCT].t1 = clock();
@@ -85,13 +83,12 @@ Sample test_stc_vector() {
c_forrange (N) cvec_x_push(&con, crand() & mask2);
s.test[FIND].t1 = clock();
size_t sum = 0;
- //cvec_x_iter it, end = cvec_x_end(&con);
- //c_forrange (S) if ((it = cvec_x_find(&con, crand() & mask2)).ref != end.ref) sum += *it.ref;
+ c_forrange (R) c_forrange (i, N) sum += con.data[i];
s.test[FIND].t2 = clock();
s.test[FIND].sum = sum;
s.test[ITER].t1 = clock();
sum = 0;
- c_forrange (R) c_forrange (i, N) sum += con.data[i];
+ c_forrange (R) c_foreach (i, cvec_x, con) sum += *i.ref;
s.test[ITER].t2 = clock();
s.test[ITER].sum = sum;
s.test[DESTRUCT].t1 = clock();