From d9754cdda30a09189d45a074d66709f5b70d9918 Mon Sep 17 00:00:00 2001 From: cxl Date: Sat, 23 Feb 2013 16:11:14 +0000 Subject: [PATCH] InVectorCache git-svn-id: svn://ultimatepp.org/upp/trunk@5852 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- benchmarks/InVectorCache/InVectorCache.cpp | 55 ++++++++++++++++++++++ benchmarks/InVectorCache/InVectorCache.upp | 9 ++++ benchmarks/InVectorCache/init | 4 ++ 3 files changed, 68 insertions(+) create mode 100644 benchmarks/InVectorCache/InVectorCache.cpp create mode 100644 benchmarks/InVectorCache/InVectorCache.upp create mode 100644 benchmarks/InVectorCache/init 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