diff options
Diffstat (limited to 'misc/benchmarks/plotbench')
| -rw-r--r-- | misc/benchmarks/plotbench/cdeq_benchmark.cpp | 15 | ||||
| -rw-r--r-- | misc/benchmarks/plotbench/clist_benchmark.cpp | 8 | ||||
| -rw-r--r-- | misc/benchmarks/plotbench/cmap_benchmark.cpp | 8 | ||||
| -rw-r--r-- | misc/benchmarks/plotbench/cpque_benchmark.cpp | 5 | ||||
| -rw-r--r-- | misc/benchmarks/plotbench/csmap_benchmark.cpp | 8 | ||||
| -rw-r--r-- | misc/benchmarks/plotbench/cvec_benchmark.cpp | 21 | ||||
| -rw-r--r-- | misc/benchmarks/plotbench/plot.py | 11 | ||||
| -rw-r--r-- | misc/benchmarks/plotbench/run_all.bat | 6 | ||||
| -rw-r--r-- | misc/benchmarks/plotbench/run_clang.sh | 12 | ||||
| -rw-r--r-- | misc/benchmarks/plotbench/run_gcc.sh | 12 | ||||
| -rw-r--r-- | misc/benchmarks/plotbench/run_vc.bat | 6 |
11 files changed, 53 insertions, 59 deletions
diff --git a/misc/benchmarks/plotbench/cdeq_benchmark.cpp b/misc/benchmarks/plotbench/cdeq_benchmark.cpp index bb0e28c8..d11b4103 100644 --- a/misc/benchmarks/plotbench/cdeq_benchmark.cpp +++ b/misc/benchmarks/plotbench/cdeq_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 = 50000000, 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; } @@ -44,14 +44,12 @@ Sample test_std_deque() { c_forrange (N) con.push_back(crand() & mask2); s.test[FIND].t1 = clock(); size_t sum = 0; - // Iteration - not inherent find - skipping - //container::iterator it; - //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(); @@ -89,13 +87,12 @@ Sample test_stc_deque() { c_forrange (N) cdeq_x_push_back(&con, crand() & mask2); s.test[FIND].t1 = clock(); size_t sum = 0; - //cdeq_x_iter it, end = cdeq_x_end(&con); - //c_forrange (S) if ((it = cdeq_x_find(&con, crand() & mask2)).ref != end.ref) sum += *it.ref; + c_forrange (R) c_forrange (i, N) sum += *cdeq_x_at(&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.data[i]; + c_forrange (R) c_foreach (i, cdeq_x, con) sum += *i.ref; s.test[ITER].t2 = clock(); s.test[ITER].sum = sum; s.test[DESTRUCT].t1 = clock(); diff --git a/misc/benchmarks/plotbench/clist_benchmark.cpp b/misc/benchmarks/plotbench/clist_benchmark.cpp index 01bfbf83..8fdfddba 100644 --- a/misc/benchmarks/plotbench/clist_benchmark.cpp +++ b/misc/benchmarks/plotbench/clist_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 = 10000000, S = 0x3ffc, R = 4}; +enum {SAMPLES = 2, N = 10000000, R = 4}; uint64_t seed = 1, mask1 = 0xfffffff, mask2 = 0xffff; static float secs(Range s) { return (float)(s.t2 - s.t1) / CLOCKS_PER_SEC; } @@ -45,7 +45,6 @@ Sample test_std_forward_list() { 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; s.test[FIND].t2 = clock(); s.test[FIND].sum = sum; s.test[ITER].t1 = clock(); @@ -86,8 +85,7 @@ Sample test_stc_forward_list() { c_forrange (N) clist_x_push_front(&con, crand() & mask2); s.test[FIND].t1 = clock(); size_t sum = 0; - //clist_x_iter it, end = clist_x_end(&con); - //c_forrange (S) if ((it = clist_x_find(&con, crand() & mask2)).ref != end.ref) sum += *it.ref; + //clist iteration - skipping s.test[FIND].t2 = clock(); s.test[FIND].sum = sum; s.test[ITER].t1 = clock(); diff --git a/misc/benchmarks/plotbench/cmap_benchmark.cpp b/misc/benchmarks/plotbench/cmap_benchmark.cpp index 6b2edbd7..c7957bb7 100644 --- a/misc/benchmarks/plotbench/cmap_benchmark.cpp +++ b/misc/benchmarks/plotbench/cmap_benchmark.cpp @@ -8,7 +8,7 @@ #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 = 2000000, R = 4}; @@ -47,12 +47,14 @@ Sample test_std_unordered_map() { s.test[FIND].t1 = clock(); size_t sum = 0; container::iterator it; - c_forrange (N) if ((it = con.find(crand() & mask1)) != con.end()) sum += it->second; + c_forrange (N) + if ((it = con.find(crand() & mask1)) != con.end()) + sum += it->second; s.test[FIND].t2 = clock(); s.test[FIND].sum = sum; s.test[ITER].t1 = clock(); sum = 0; - c_forrange (R) for (auto i: con) sum += i.second; + c_forrange (R) for (const auto& i: con) sum += i.second; s.test[ITER].t2 = clock(); s.test[ITER].sum = sum; s.test[DESTRUCT].t1 = clock(); diff --git a/misc/benchmarks/plotbench/cpque_benchmark.cpp b/misc/benchmarks/plotbench/cpque_benchmark.cpp index 2d4c7a28..aafc9eb0 100644 --- a/misc/benchmarks/plotbench/cpque_benchmark.cpp +++ b/misc/benchmarks/plotbench/cpque_benchmark.cpp @@ -37,7 +37,8 @@ void stc_test() { int N = 10000000; - c_auto (cpque_f, pq) + cpque_f pq = {0}; + c_defer(cpque_f_drop(&pq)) { csrand(seed); clock_t start = clock(); @@ -58,7 +59,7 @@ void stc_test() } -int main() +int main(void) { puts("STD P.QUEUE:"); std_test(); diff --git a/misc/benchmarks/plotbench/csmap_benchmark.cpp b/misc/benchmarks/plotbench/csmap_benchmark.cpp index 60f2db49..480163ed 100644 --- a/misc/benchmarks/plotbench/csmap_benchmark.cpp +++ b/misc/benchmarks/plotbench/csmap_benchmark.cpp @@ -8,7 +8,7 @@ #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 = 1000000, R = 4}; @@ -47,12 +47,14 @@ Sample test_std_map() { s.test[FIND].t1 = clock(); size_t sum = 0; container::iterator it; - c_forrange (N) if ((it = con.find(crand() & mask1)) != con.end()) sum += it->second; + c_forrange (N) + if ((it = con.find(crand() & mask1)) != con.end()) + sum += it->second; s.test[FIND].t2 = clock(); s.test[FIND].sum = sum; s.test[ITER].t1 = clock(); sum = 0; - c_forrange (R) for (auto i: con) sum += i.second; + c_forrange (R) for (const auto& i: con) sum += i.second; s.test[ITER].t2 = clock(); s.test[ITER].sum = sum; s.test[DESTRUCT].t1 = clock(); diff --git a/misc/benchmarks/plotbench/cvec_benchmark.cpp b/misc/benchmarks/plotbench/cvec_benchmark.cpp index c488a01c..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 = 80000000, 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(); @@ -71,27 +69,26 @@ Sample test_stc_vector() { s.test[INSERT].t1 = clock(); container con = cvec_x_init(); csrand(seed); - c_forrange (N) cvec_x_push_back(&con, crand() & mask1); + c_forrange (N) cvec_x_push(&con, crand() & mask1); s.test[INSERT].t2 = clock(); s.test[INSERT].sum = cvec_x_size(&con); s.test[ERASE].t1 = clock(); - c_forrange (N) { cvec_x_pop_back(&con); } + c_forrange (N) { cvec_x_pop(&con); } s.test[ERASE].t2 = clock(); s.test[ERASE].sum = cvec_x_size(&con); cvec_x_drop(&con); }{ csrand(seed); container con = cvec_x_init(); - c_forrange (N) cvec_x_push_back(&con, crand() & mask2); + 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(); diff --git a/misc/benchmarks/plotbench/plot.py b/misc/benchmarks/plotbench/plot.py index 0ba92264..4a02c6b2 100644 --- a/misc/benchmarks/plotbench/plot.py +++ b/misc/benchmarks/plotbench/plot.py @@ -4,7 +4,7 @@ import pandas as pd import matplotlib.pyplot as plt #sns.set_theme(style="whitegrid") -comp = ['All compilers', 'Mingw-g++-11.3.0', 'Win-Clang-14.0.1', 'VC-19.28'] +comp = ['All compilers', 'Mingw-g++-13.1.0', 'Win-Clang-16.0.5', 'VC-19.36'] n = int(sys.argv[1]) if len(sys.argv) > 1 else 0 file = sys.argv[2] if len(sys.argv) > 2 else 'plot_win.csv' df = pd.read_csv(file) @@ -12,13 +12,12 @@ df = df[df.Method != 'total'] if n > 0: df = df[df.Compiler == comp[n]] -g = sns.catplot(data=df, x='Method', y='Seconds', hue='Library', col='C', kind='bar', - ci=68, legend=False, col_wrap=2, sharex=False, aspect=1.4, height=3.1) +g = sns.catplot(data=df, x='Method', y='Seconds', hue='Library', col='C', kind='bar', orient='v', + errorbar=('ci', 68), legend=False, col_wrap=2, sharex=False, aspect=1.4, height=3.0) g.set_xlabels('') -g.add_legend(bbox_to_anchor=(0.75, 0.2), borderaxespad=0.) - -g.fig.subplots_adjust(top=0.90, left=0.06, bottom=0.07) +g.add_legend(bbox_to_anchor=(0.75, 0.2), borderaxespad=0) +g.fig.subplots_adjust(top=0.90, left=0.08, right=0.98, bottom=0.04, hspace=0.4) g.fig.suptitle('Benchmark STC vs c++ std containers: %s' % comp[n], fontsize=15, y=0.98) plt.show() diff --git a/misc/benchmarks/plotbench/run_all.bat b/misc/benchmarks/plotbench/run_all.bat index 98913a50..de380531 100644 --- a/misc/benchmarks/plotbench/run_all.bat +++ b/misc/benchmarks/plotbench/run_all.bat @@ -1,7 +1,5 @@ -set out=plot_win.csv +@set out=plot_win.csv echo Compiler,Library,C,Method,Seconds,Ratio> %out% -echo gcc sh run_gcc.sh >> %out% -echo clang sh run_clang.sh >> %out% -REM call run_vc.bat >> %out% +call run_vc.bat >> %out% diff --git a/misc/benchmarks/plotbench/run_clang.sh b/misc/benchmarks/plotbench/run_clang.sh index 096e71be..4f649cbc 100644 --- a/misc/benchmarks/plotbench/run_clang.sh +++ b/misc/benchmarks/plotbench/run_clang.sh @@ -1,12 +1,12 @@ exe='' if [ "$OS" = "Windows_NT" ] ; then exe=".exe" ; fi -clang++ -I../include -O3 -o cdeq_benchmark$exe cdeq_benchmark.cpp -clang++ -I../include -O3 -o clist_benchmark$exe clist_benchmark.cpp -clang++ -I../include -O3 -o cmap_benchmark$exe cmap_benchmark.cpp -clang++ -I../include -O3 -o csmap_benchmark$exe csmap_benchmark.cpp -clang++ -I../include -O3 -o cvec_benchmark$exe cvec_benchmark.cpp +clang -DNDEBUG -I../../include -O3 -o cdeq_benchmark$exe cdeq_benchmark.cpp -lstdc++ +clang -DNDEBUG -I../../include -O3 -o clist_benchmark$exe clist_benchmark.cpp -lstdc++ +clang -DNDEBUG -I../../include -O3 -o cmap_benchmark$exe cmap_benchmark.cpp -lstdc++ +clang -DNDEBUG -I../../include -O3 -o csmap_benchmark$exe csmap_benchmark.cpp -lstdc++ +clang -DNDEBUG -I../../include -O3 -o cvec_benchmark$exe cvec_benchmark.cpp -lstdc++ -c='Win-Clang-14.0.1' +c='Win-Clang-16.0.5' ./cdeq_benchmark$exe $c ./clist_benchmark$exe $c ./cmap_benchmark$exe $c diff --git a/misc/benchmarks/plotbench/run_gcc.sh b/misc/benchmarks/plotbench/run_gcc.sh index 5249ed1e..0bd2d6ee 100644 --- a/misc/benchmarks/plotbench/run_gcc.sh +++ b/misc/benchmarks/plotbench/run_gcc.sh @@ -1,10 +1,10 @@ -g++ -I../include -O3 -o cdeq_benchmark cdeq_benchmark.cpp -g++ -I../include -O3 -o clist_benchmark clist_benchmark.cpp -g++ -I../include -O3 -o cmap_benchmark cmap_benchmark.cpp -g++ -I../include -O3 -o csmap_benchmark csmap_benchmark.cpp -g++ -I../include -O3 -o cvec_benchmark cvec_benchmark.cpp +g++ -DNDEBUG -I../../include -O3 -o cdeq_benchmark cdeq_benchmark.cpp +g++ -DNDEBUG -I../../include -O3 -o clist_benchmark clist_benchmark.cpp +g++ -DNDEBUG -I../../include -O3 -o cmap_benchmark cmap_benchmark.cpp +g++ -DNDEBUG -I../../include -O3 -o csmap_benchmark csmap_benchmark.cpp +g++ -DNDEBUG -I../../include -O3 -o cvec_benchmark cvec_benchmark.cpp -c='Mingw-g++-11.3.0' +c='Mingw-g++-13.1.0' ./cdeq_benchmark $c ./clist_benchmark $c ./cmap_benchmark $c diff --git a/misc/benchmarks/plotbench/run_vc.bat b/misc/benchmarks/plotbench/run_vc.bat index dc4938f8..c00d059b 100644 --- a/misc/benchmarks/plotbench/run_vc.bat +++ b/misc/benchmarks/plotbench/run_vc.bat @@ -1,14 +1,14 @@ @echo off -if "%VSINSTALLDIR%"=="" call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat" >nul +if "%VSINSTALLDIR%"=="" call "C:\Program Files (x86)\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat" >nul cl.exe -nologo -EHsc -std:c++latest -I../include -O2 cdeq_benchmark.cpp >nul cl.exe -nologo -EHsc -std:c++latest -I../include -O2 clist_benchmark.cpp >nul cl.exe -nologo -EHsc -std:c++latest -I../include -O2 cmap_benchmark.cpp >nul cl.exe -nologo -EHsc -std:c++latest -I../include -O2 csmap_benchmark.cpp >nul cl.exe -nologo -EHsc -std:c++latest -I../include -O2 cvec_benchmark.cpp >nul -del *.obj >nul +if exist *obj del *.obj -set c=VC-19.28 +set c=VC-19.36 cdeq_benchmark.exe %c% clist_benchmark.exe %c% cmap_benchmark.exe %c% |
