diff --git a/benchmarks/InVectorCache/InVectorCache.cpp b/benchmarks/InVectorCache/InVectorCache.cpp new file mode 100644 index 000000000..75254b459 --- /dev/null +++ b/benchmarks/InVectorCache/InVectorCache.cpp @@ -0,0 +1,55 @@ +#include + +using namespace Upp; + +CONSOLE_APP_MAIN +{ + int N = 10; + InVector x; + for(int i = 0; i < 1000000; i++) + x.Add(Random(1000)); + { + RTIMING("Simple scan"); + int m = 0; + for(int j = 0; j < N; j++) { + for(int i = 0; i < x.GetCount(); i++) + m += x[i]; + for(int i = x.GetCount(); --i >= 0;) + m += x[i]; + } + RDUMP(m); + } + { + RTIMING("Single InVector, problematic scan"); + int m = 0; + for(int j = 0; j < N; j++) { + for(int i = 0; i < x.GetCount(); i++) + m += x[i] + x[x.GetCount() - i - 1]; + } + RDUMP(m); + } + { + InVector y; + y <<= x; + RTIMING("Two InVectors"); + int m = 0; + for(int j = 0; j < N; j++) { + for(int i = 0; i < x.GetCount(); i++) + m += x[i] + y[i]; + } + RDUMP(m); + } + { + InVector y; + y <<= x; + RTIMING("Two InVectors, two simple scans"); + int m = 0; + for(int j = 0; j < N; j++) { + for(int i = 0; i < x.GetCount(); i++) + m += x[i]; + for(int i = y.GetCount(); --i >= 0;) + m += y[i]; + } + RDUMP(m); + } +} diff --git a/benchmarks/InVectorCache/InVectorCache.upp b/benchmarks/InVectorCache/InVectorCache.upp new file mode 100644 index 000000000..b27cc7e43 --- /dev/null +++ b/benchmarks/InVectorCache/InVectorCache.upp @@ -0,0 +1,9 @@ +uses + Core; + +file + InVectorCache.cpp; + +mainconfig + "" = "SSE2"; + diff --git a/benchmarks/InVectorCache/init b/benchmarks/InVectorCache/init new file mode 100644 index 000000000..2f74ccc17 --- /dev/null +++ b/benchmarks/InVectorCache/init @@ -0,0 +1,4 @@ +#ifndef _InVectorCache_icpp_init_stub +#define _InVectorCache_icpp_init_stub +#include "Core/init" +#endif