Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
use non-trivial values for arrayops
Browse files Browse the repository at this point in the history
- e.g. to avoid optimizing out `* 1`
  • Loading branch information
MartinNowak committed Aug 5, 2016
1 parent cf03a70 commit d01bfce
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions benchmark/arrayops/arrayops.d
Expand Up @@ -12,9 +12,9 @@ float[6] getLatencies(T, string op)()
{
enum N = 256;
auto a = new T[](N), b = new T[](N), c = new T[](N);
a[] = 3;
b[] = 2;
c[] = 1;
a[] = 19;
b[] = 11;
c[] = 7;
float[6] latencies = float.max;
foreach (i, ref latency; latencies)
{
Expand All @@ -25,7 +25,7 @@ float[6] getLatencies(T, string op)()
foreach (off; 0 .. 1_024)
{
off &= 127;
enum op = op.replace("const", "1").replace("a",
enum op = op.replace("const", "7").replace("a",
"a[off .. off + len]").replace("b",
"b[off .. off + len]").replace("c", "c[off .. off + len]");
mixin(op ~ ";");
Expand All @@ -41,9 +41,9 @@ float[4] getThroughput(T, string op)()
{
enum N = (40 * 1024 * 1024 + 64) / T.sizeof;
auto a = new T[](N), b = new T[](N), c = new T[](N);
a[] = 3;
b[] = 2;
c[] = 1;
a[] = 19;
b[] = 11;
c[] = 7;
float[4] latencies = float.max;
size_t[4] lengths = [
8 * 1024 / T.sizeof, 32 * 1024 / T.sizeof, 512 * 1024 / T.sizeof, 32 * 1024 * 1024 / T
Expand All @@ -58,7 +58,7 @@ float[4] getThroughput(T, string op)()
foreach (off; size_t(0) .. size_t(64))
{
off = off * len + (off % (64 / T.sizeof));
enum op = op.replace("const", "1").replace("a",
enum op = op.replace("const", "7").replace("a",
"a[off .. off + len]").replace("b",
"b[off .. off + len]").replace("c", "c[off .. off + len]");
mixin(op ~ ";");
Expand Down

0 comments on commit d01bfce

Please sign in to comment.