From acd1c5560ac49b0812e258d35107603b7c8fe6f7 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Wed, 10 Feb 2021 23:17:01 +0100 Subject: Benchmark image added. --- benchmarks/cvec_benchmark.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'benchmarks/cvec_benchmark.cpp') diff --git a/benchmarks/cvec_benchmark.cpp b/benchmarks/cvec_benchmark.cpp index 24931273..e7a4c869 100644 --- a/benchmarks/cvec_benchmark.cpp +++ b/benchmarks/cvec_benchmark.cpp @@ -8,9 +8,10 @@ #endif enum {INSERT, ERASE, FIND, ITER, DESTRUCT, N_TESTS}; +const char* operations[] = {"insert", "erase", "find", "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 = 3, N = 100000000}; +enum {SAMPLES = 3, N = 150000000}; uint64_t seed = 1, mask1 = 0xfffffff; @@ -21,7 +22,7 @@ using_cvec(x, size_t); #ifdef __cplusplus Sample test_std_vector() { typedef std::vector container; - Sample s = {"std-vector"}; + Sample s = {"std,vector"}; { s.test[INSERT].t1 = clock(); container con; @@ -48,12 +49,15 @@ Sample test_std_vector() { s.test[DESTRUCT].sum = 0; return s; } +#else +Sample test_std_vector() { Sample s = {"std-vector"}; return s;} #endif + Sample test_stc_vector() { typedef cvec_x container; - Sample s = {"stc-vector"}; + Sample s = {"STC,vector"}; { s.test[INSERT].t1 = clock(); container con = cvec_x_init(); @@ -83,11 +87,10 @@ Sample test_stc_vector() { return s; } -int main() +int main(int argc, char* argv[]) { Sample std_s[SAMPLES + 1] = {0}, stc_s[SAMPLES + 1] = {0}; c_forrange (i, int, SAMPLES) { - printf("vector benchmark sample %d\n", i); std_s[i] = test_std_vector(); stc_s[i] = test_stc_vector(); if (i > 0) c_forrange (j, int, N_TESTS) { @@ -98,11 +101,9 @@ int main() } float std_sum = 0, stc_sum = 0; c_forrange (j, N_TESTS) { std_sum += secs(std_s[0].test[j]); stc_sum += secs(stc_s[0].test[j]); } - printf("Test-name, Insert, Erase, Find, Iter, Destruct, Total, Ratio\n"); - - printf("%s", std_s[0].name); c_forrange (j, N_TESTS) printf(", %.3f", secs(std_s[0].test[j])); - printf(", %.3f, 1.000\n", std_sum); - - printf("%s", stc_s[0].name); c_forrange (j, N_TESTS) printf(", %.3f", secs(stc_s[0].test[j])); - printf(", %.3f, %.3f\n", stc_sum, std_sum/stc_sum); + if (argv[1][0] == '1') printf("compiler,library,container,count,operation,time,ratio\n"); + c_forrange (j, N_TESTS) printf("%s,%s,%d,%s,%.3f,%.3f\n", argv[2], std_s[0].name, N, operations[j], secs(std_s[0].test[j]), 1.0f); + printf("%s,%s,%d,%s,%.3f,%.3f\n", argv[2], std_s[0].name, N, "total", std_sum, 1.0f); + c_forrange (j, N_TESTS) printf("%s,%s,%d,%s,%.3f,%.3f\n", argv[2], stc_s[0].name, N, operations[j], secs(stc_s[0].test[j]), secs(std_s[0].test[j]) ? secs(stc_s[0].test[j])/secs(std_s[0].test[j]) : 1.0f); + printf("%s,%s,%d,%s,%.3f,%.3f\n", argv[2], stc_s[0].name, N, "total", stc_sum, stc_sum/std_sum); } -- cgit v1.2.3