Browse Source

Unroll perf test loops to reduce loop overhead

With less loop overhead the micro benchmarks provide clearer results on
how the actual operation being tested behaves.
pull/383/head
Sami Vaarala 9 years ago
parent
commit
b41371be94
  1. 11
      tests/perf/test-array-read.js
  2. 14
      tests/perf/test-array-read.lua
  3. 11
      tests/perf/test-array-read.pl
  4. 11
      tests/perf/test-array-read.py
  5. 11
      tests/perf/test-array-read.rb
  6. 11
      tests/perf/test-array-write.js
  7. 11
      tests/perf/test-array-write.lua
  8. 11
      tests/perf/test-array-write.pl
  9. 11
      tests/perf/test-array-write.py
  10. 11
      tests/perf/test-array-write.rb
  11. 29
      tests/perf/test-break-fast.js
  12. 56
      tests/perf/test-break-slow.js
  13. 11
      tests/perf/test-buffer-nodejs-read.js
  14. 11
      tests/perf/test-buffer-nodejs-write.js
  15. 11
      tests/perf/test-buffer-object-read.js
  16. 11
      tests/perf/test-buffer-object-write.js
  17. 11
      tests/perf/test-buffer-plain-read.js
  18. 11
      tests/perf/test-buffer-plain-write.js
  19. 11
      tests/perf/test-call-basic.js
  20. 11
      tests/perf/test-call-basic.lua
  21. 11
      tests/perf/test-call-basic.pl
  22. 11
      tests/perf/test-call-basic.py
  23. 11
      tests/perf/test-call-basic.rb
  24. 11
      tests/perf/test-call-native.js
  25. 11
      tests/perf/test-compile-mandel-nofrac.js
  26. 11
      tests/perf/test-compile-mandel.js
  27. 11
      tests/perf/test-compile-short.js
  28. 29
      tests/perf/test-continue-fast.js
  29. 56
      tests/perf/test-continue-slow.js
  30. 11
      tests/perf/test-prop-read.js
  31. 14
      tests/perf/test-prop-read.lua
  32. 11
      tests/perf/test-prop-read.pl
  33. 11
      tests/perf/test-prop-read.py
  34. 11
      tests/perf/test-prop-read.rb
  35. 11
      tests/perf/test-prop-write.js
  36. 11
      tests/perf/test-prop-write.lua
  37. 11
      tests/perf/test-prop-write.pl
  38. 11
      tests/perf/test-prop-write.py
  39. 11
      tests/perf/test-prop-write.rb
  40. 11
      tests/perf/test-regexp-string-parse.js
  41. 11
      tests/perf/test-regexp-string-parse.py

11
tests/perf/test-array-read.js

@ -7,7 +7,16 @@ function test() {
var i;
var ign;
for (i = 0; i < 1e8; i++) {
for (i = 0; i < 1e7; i++) {
ign = arr[7];
ign = arr[7];
ign = arr[7];
ign = arr[7];
ign = arr[7];
ign = arr[7];
ign = arr[7];
ign = arr[7];
ign = arr[7];
ign = arr[7];
}
}

14
tests/perf/test-array-read.lua

@ -1,7 +1,17 @@
function test()
local arr = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }
for i=1,1e8 do
local ign = arr[8]
local ign
for i=1,1e7 do
ign = arr[8]
ign = arr[8]
ign = arr[8]
ign = arr[8]
ign = arr[8]
ign = arr[8]
ign = arr[8]
ign = arr[8]
ign = arr[8]
ign = arr[8]
end
end

11
tests/perf/test-array-read.pl

@ -3,7 +3,16 @@ sub test {
my $i;
my $ign;
for ($i = 0; $i < 1e8; $i++) {
for ($i = 0; $i < 1e7; $i++) {
$ign = $arr[7];
$ign = $arr[7];
$ign = $arr[7];
$ign = $arr[7];
$ign = $arr[7];
$ign = $arr[7];
$ign = $arr[7];
$ign = $arr[7];
$ign = $arr[7];
$ign = $arr[7];
}
}

11
tests/perf/test-array-read.py

@ -1,7 +1,16 @@
def test():
arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ];
i = 0
while i < 1e8:
while i < 1e7:
ign = arr[7]
ign = arr[7]
ign = arr[7]
ign = arr[7]
ign = arr[7]
ign = arr[7]
ign = arr[7]
ign = arr[7]
ign = arr[7]
ign = arr[7]
i += 1

11
tests/perf/test-array-read.rb

@ -1,7 +1,16 @@
def test()
arr = Array[ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
i = 0
while i < 1e8 do
while i < 1e7 do
ign = arr[7]
ign = arr[7]
ign = arr[7]
ign = arr[7]
ign = arr[7]
ign = arr[7]
ign = arr[7]
ign = arr[7]
ign = arr[7]
ign = arr[7]
i += 1
end

11
tests/perf/test-array-write.js

@ -6,7 +6,16 @@ function test() {
var arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ];
var i;
for (i = 0; i < 1e8; i++) {
for (i = 0; i < 1e7; i++) {
arr[7] = 234;
arr[7] = 234;
arr[7] = 234;
arr[7] = 234;
arr[7] = 234;
arr[7] = 234;
arr[7] = 234;
arr[7] = 234;
arr[7] = 234;
arr[7] = 234;
}
}

11
tests/perf/test-array-write.lua

@ -1,6 +1,15 @@
function test()
local arr = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }
for i=1,1e8 do
for i=1,1e7 do
arr[8] = 234
arr[8] = 234
arr[8] = 234
arr[8] = 234
arr[8] = 234
arr[8] = 234
arr[8] = 234
arr[8] = 234
arr[8] = 234
arr[8] = 234
end
end

11
tests/perf/test-array-write.pl

@ -3,7 +3,16 @@ sub test {
my $i;
my $ign;
for ($i = 0; $i < 1e8; $i++) {
for ($i = 0; $i < 1e7; $i++) {
$arr[7] = 234;
$arr[7] = 234;
$arr[7] = 234;
$arr[7] = 234;
$arr[7] = 234;
$arr[7] = 234;
$arr[7] = 234;
$arr[7] = 234;
$arr[7] = 234;
$arr[7] = 234;
}
}

11
tests/perf/test-array-write.py

@ -1,7 +1,16 @@
def test():
arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ];
i = 0
while i < 1e8:
while i < 1e7:
arr[7] = 234
arr[7] = 234
arr[7] = 234
arr[7] = 234
arr[7] = 234
arr[7] = 234
arr[7] = 234
arr[7] = 234
arr[7] = 234
arr[7] = 234
i += 1

11
tests/perf/test-array-write.rb

@ -1,7 +1,16 @@
def test()
arr = Array[ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
i = 0
while i < 1e8 do
while i < 1e7 do
arr[7] = 234
arr[7] = 234
arr[7] = 234
arr[7] = 234
arr[7] = 234
arr[7] = 234
arr[7] = 234
arr[7] = 234
arr[7] = 234
arr[7] = 234
i += 1
end

29
tests/perf/test-break-fast.js

@ -1,6 +1,33 @@
function test() {
var i;
for (i = 0; i < 1e8; i++) {
for (i = 0; i < 1e7; i++) {
do {
break;
} while (0);
do {
break;
} while (0);
do {
break;
} while (0);
do {
break;
} while (0);
do {
break;
} while (0);
do {
break;
} while (0);
do {
break;
} while (0);
do {
break;
} while (0);
do {
break;
} while (0);
do {
break;
} while (0);

56
tests/perf/test-break-slow.js

@ -1,6 +1,60 @@
function test() {
var i;
for (i = 0; i < 1e8; i++) {
for (i = 0; i < 1e7; i++) {
do {
try {
break;
} finally {
}
} while (0);
do {
try {
break;
} finally {
}
} while (0);
do {
try {
break;
} finally {
}
} while (0);
do {
try {
break;
} finally {
}
} while (0);
do {
try {
break;
} finally {
}
} while (0);
do {
try {
break;
} finally {
}
} while (0);
do {
try {
break;
} finally {
}
} while (0);
do {
try {
break;
} finally {
}
} while (0);
do {
try {
break;
} finally {
}
} while (0);
do {
try {
break;

11
tests/perf/test-buffer-nodejs-read.js

@ -4,7 +4,16 @@ function test() {
print(typeof b);
for (i = 0; i < 1e8; i++) {
for (i = 0; i < 1e7; i++) {
void b[100];
void b[100];
void b[100];
void b[100];
void b[100];
void b[100];
void b[100];
void b[100];
void b[100];
void b[100];
}
}

11
tests/perf/test-buffer-nodejs-write.js

@ -4,7 +4,16 @@ function test() {
print(typeof b);
for (i = 0; i < 1e8; i++) {
for (i = 0; i < 1e7; i++) {
b[100] = 123;
b[100] = 123;
b[100] = 123;
b[100] = 123;
b[100] = 123;
b[100] = 123;
b[100] = 123;
b[100] = 123;
b[100] = 123;
b[100] = 123;
}
}

11
tests/perf/test-buffer-object-read.js

@ -4,7 +4,16 @@ function test() {
print(typeof b);
for (i = 0; i < 1e8; i++) {
for (i = 0; i < 1e7; i++) {
void b[100];
void b[100];
void b[100];
void b[100];
void b[100];
void b[100];
void b[100];
void b[100];
void b[100];
void b[100];
}
}

11
tests/perf/test-buffer-object-write.js

@ -4,7 +4,16 @@ function test() {
print(typeof b);
for (i = 0; i < 1e8; i++) {
for (i = 0; i < 1e7; i++) {
b[100] = 123;
b[100] = 123;
b[100] = 123;
b[100] = 123;
b[100] = 123;
b[100] = 123;
b[100] = 123;
b[100] = 123;
b[100] = 123;
b[100] = 123;
}
}

11
tests/perf/test-buffer-plain-read.js

@ -4,7 +4,16 @@ function test() {
print(typeof b);
for (i = 0; i < 1e8; i++) {
for (i = 0; i < 1e7; i++) {
void b[100];
void b[100];
void b[100];
void b[100];
void b[100];
void b[100];
void b[100];
void b[100];
void b[100];
void b[100];
}
}

11
tests/perf/test-buffer-plain-write.js

@ -4,7 +4,16 @@ function test() {
print(typeof b);
for (i = 0; i < 1e8; i++) {
for (i = 0; i < 1e7; i++) {
b[100] = 123;
b[100] = 123;
b[100] = 123;
b[100] = 123;
b[100] = 123;
b[100] = 123;
b[100] = 123;
b[100] = 123;
b[100] = 123;
b[100] = 123;
}
}

11
tests/perf/test-call-basic.js

@ -7,7 +7,16 @@ function test() {
function f() { return; }
for (i = 0; i < 1e8; i++) {
for (i = 0; i < 1e7; i++) {
f();
f();
f();
f();
f();
f();
f();
f();
f();
f();
}
}

11
tests/perf/test-call-basic.lua

@ -3,7 +3,16 @@ function test()
return
end
for i=1,1e8 do
for i=1,1e7 do
f()
f()
f()
f()
f()
f()
f()
f()
f()
f()
end
end

11
tests/perf/test-call-basic.pl

@ -4,7 +4,16 @@ sub test {
sub f { return; }
$i = 0;
for ($i = 0; $i < 1e8; $i++) {
for ($i = 0; $i < 1e7; $i++) {
f();
f();
f();
f();
f();
f();
f();
f();
f();
f();
}
}

11
tests/perf/test-call-basic.py

@ -3,7 +3,16 @@ def test():
return
i = 0
while i < 1e8:
while i < 1e7:
f()
f()
f()
f()
f()
f()
f()
f()
f()
f()
i += 1

11
tests/perf/test-call-basic.rb

@ -2,7 +2,16 @@ def test()
def f() return end
i = 0
while i < 1e8 do
while i < 1e7 do
f()
f()
f()
f()
f()
f()
f()
f()
f()
f()
i += 1
end

11
tests/perf/test-call-native.js

@ -3,11 +3,20 @@ function test() {
for (var i = 0; i < 1e3; i++) {
arr[i] = i;
}
for (var i = 0; i < 1e5; i++) {
for (var i = 0; i < 1e4; i++) {
// Each .forEach() call is a native call so that return 123 causes a
// return-to-native situation which was previously a longjmp.
arr.forEach(function () { return 123; });
arr.forEach(function () { return 123; });
arr.forEach(function () { return 123; });
arr.forEach(function () { return 123; });
arr.forEach(function () { return 123; });
arr.forEach(function () { return 123; });
arr.forEach(function () { return 123; });
arr.forEach(function () { return 123; });
arr.forEach(function () { return 123; });
arr.forEach(function () { return 123; });
}
}

11
tests/perf/test-compile-mandel-nofrac.js

@ -7,7 +7,16 @@ function test() {
var i;
var src = "(function mandel() {\n var w = 80;\n var h = 40;\n var iter = 100;\n var i, j, k;\n var x0, y0, xx, yy, c, xx2, yy2;\n var res;\n\n for (i = 0; i - h; i += 1) {\n y0 = (i / h) * 4 - 2;\n\n res = [];\n\n for (j = 0; j - w; j += 1) {\n x0 = (j / w) * 4 - 2;\n\n xx = 0;\n yy = 0;\n c = \"#\";\n\n for (k = 0; k - iter; k += 1) {\n /* z -> z^2 + c\n * -> (xx+i*yy)^2 + (x0+i*y0)\n * -> xx*xx+i*2*xx*yy-yy*yy + x0 + i*y0\n * -> (xx*xx - yy*yy + x0) + i*(2*xx*yy + y0)\n */\n\n xx2 = xx*xx;\n yy2 = yy*yy;\n\n if (Math.max(0, 4 - (xx2 + yy2))) {\n yy = 2*xx*yy + y0;\n xx = xx2 - yy2 + x0;\n } else {\n /* xx^2 + yy^2 >= 4 */\n c = \".\";\n break;\n }\n }\n\n res[res.length] = c;\n }\n\n print(res.join(''));\n }\n})\n";
for (i = 0; i < 1e5; i++) {
for (i = 0; i < 1e4; i++) {
void eval(src);
void eval(src);
void eval(src);
void eval(src);
void eval(src);
void eval(src);
void eval(src);
void eval(src);
void eval(src);
void eval(src);
}
}

11
tests/perf/test-compile-mandel.js

@ -2,7 +2,16 @@ function test() {
var i;
var src = "(function mandel() {\n var w = 80;\n var h = 40;\n var iter = 100;\n var i, j, k;\n var x0, y0, xx, yy, c, xx2, yy2;\n var res;\n\n for (i = 0; i - h; i += 1) {\n y0 = (i / h) * 4.0 - 2.0;\n\n res = [];\n\n for (j = 0; j - w; j += 1) {\n x0 = (j / w) * 4.0 - 2.0;\n\n xx = 0;\n yy = 0;\n c = \"#\";\n\n for (k = 0; k - iter; k += 1) {\n /* z -> z^2 + c\n * -> (xx+i*yy)^2 + (x0+i*y0)\n * -> xx*xx+i*2*xx*yy-yy*yy + x0 + i*y0\n * -> (xx*xx - yy*yy + x0) + i*(2*xx*yy + y0)\n */\n\n xx2 = xx*xx;\n yy2 = yy*yy;\n\n if (Math.max(0, 4.0 - (xx2 + yy2))) {\n yy = 2*xx*yy + y0;\n xx = xx2 - yy2 + x0;\n } else {\n /* xx^2 + yy^2 >= 4.0 */\n c = \".\";\n break;\n }\n }\n\n res[res.length] = c;\n }\n\n print(res.join(''));\n }\n})\n";
for (i = 0; i < 1e5; i++) {
for (i = 0; i < 1e4; i++) {
void eval(src);
void eval(src);
void eval(src);
void eval(src);
void eval(src);
void eval(src);
void eval(src);
void eval(src);
void eval(src);
void eval(src);
}
}

11
tests/perf/test-compile-short.js

@ -3,7 +3,16 @@ function test() {
var src = '123 + myval';
var myval = 234;
for (i = 0; i < 1e6; i++) {
for (i = 0; i < 1e5; i++) {
void eval(src);
void eval(src);
void eval(src);
void eval(src);
void eval(src);
void eval(src);
void eval(src);
void eval(src);
void eval(src);
void eval(src);
}
}

29
tests/perf/test-continue-fast.js

@ -1,6 +1,33 @@
function test() {
var i;
for (i = 0; i < 1e8; i++) {
for (i = 0; i < 1e7; i++) {
do {
continue;
} while (0);
do {
continue;
} while (0);
do {
continue;
} while (0);
do {
continue;
} while (0);
do {
continue;
} while (0);
do {
continue;
} while (0);
do {
continue;
} while (0);
do {
continue;
} while (0);
do {
continue;
} while (0);
do {
continue;
} while (0);

56
tests/perf/test-continue-slow.js

@ -1,6 +1,60 @@
function test() {
var i;
for (i = 0; i < 1e8; i++) {
for (i = 0; i < 1e7; i++) {
do {
try {
continue;
} finally {
}
} while (0);
do {
try {
continue;
} finally {
}
} while (0);
do {
try {
continue;
} finally {
}
} while (0);
do {
try {
continue;
} finally {
}
} while (0);
do {
try {
continue;
} finally {
}
} while (0);
do {
try {
continue;
} finally {
}
} while (0);
do {
try {
continue;
} finally {
}
} while (0);
do {
try {
continue;
} finally {
}
} while (0);
do {
try {
continue;
} finally {
}
} while (0);
do {
try {
continue;

11
tests/perf/test-prop-read.js

@ -7,7 +7,16 @@ function test() {
var i;
var ign;
for (i = 0; i < 1e8; i++) {
for (i = 0; i < 1e7; i++) {
ign = obj.foo;
ign = obj.foo;
ign = obj.foo;
ign = obj.foo;
ign = obj.foo;
ign = obj.foo;
ign = obj.foo;
ign = obj.foo;
ign = obj.foo;
ign = obj.foo;
}
}

14
tests/perf/test-prop-read.lua

@ -1,7 +1,17 @@
function test()
local obj = { xxx1 = 1, xxx2 = 2, xxx3 = 3, xxx4 = 4, foo = 123 }
for i=1,1e8 do
local ign = obj.foo
local ign
for i=1,1e7 do
ign = obj.foo
ign = obj.foo
ign = obj.foo
ign = obj.foo
ign = obj.foo
ign = obj.foo
ign = obj.foo
ign = obj.foo
ign = obj.foo
ign = obj.foo
end
end

11
tests/perf/test-prop-read.pl

@ -3,7 +3,16 @@ sub test {
my $i;
my $ign;
for ($i = 0; $i < 1e8; $i++) {
for ($i = 0; $i < 1e7; $i++) {
$ign = $obj{'foo'};
$ign = $obj{'foo'};
$ign = $obj{'foo'};
$ign = $obj{'foo'};
$ign = $obj{'foo'};
$ign = $obj{'foo'};
$ign = $obj{'foo'};
$ign = $obj{'foo'};
$ign = $obj{'foo'};
$ign = $obj{'foo'};
}
}

11
tests/perf/test-prop-read.py

@ -1,7 +1,16 @@
def test():
obj = { 'xxx1': 1, 'xxx2': 2, 'xxx3': 3, 'xxx4': 4, 'foo': 123 }
i = 0
while i < 1e8:
while i < 1e7:
ign = obj['foo']
ign = obj['foo']
ign = obj['foo']
ign = obj['foo']
ign = obj['foo']
ign = obj['foo']
ign = obj['foo']
ign = obj['foo']
ign = obj['foo']
ign = obj['foo']
i += 1

11
tests/perf/test-prop-read.rb

@ -2,7 +2,16 @@ def test()
obj = Hash["xxx1" => 1, "xxx2" => 2, "xxx3" => 3, "xxx4" => 4, "foo" => 123];
i = 0
while i < 1e8 do
while i < 1e7 do
ign = obj['foo']
ign = obj['foo']
ign = obj['foo']
ign = obj['foo']
ign = obj['foo']
ign = obj['foo']
ign = obj['foo']
ign = obj['foo']
ign = obj['foo']
ign = obj['foo']
i += 1
end

11
tests/perf/test-prop-write.js

@ -6,7 +6,16 @@ function test() {
var obj = { xxx1: 1, xxx2: 2, xxx3: 3, xxx4: 4, foo: 123 };
var i;
for (i = 0; i < 1e8; i++) {
for (i = 0; i < 1e7; i++) {
obj.foo = 234;
obj.foo = 234;
obj.foo = 234;
obj.foo = 234;
obj.foo = 234;
obj.foo = 234;
obj.foo = 234;
obj.foo = 234;
obj.foo = 234;
obj.foo = 234;
}
}

11
tests/perf/test-prop-write.lua

@ -1,6 +1,15 @@
function test()
local obj = { xxx1 = 1, xxx2 = 2, xxx3 = 3, xxx4 = 4, foo = 123 }
for i=1,1e8 do
for i=1,1e7 do
obj.foo = 234
obj.foo = 234
obj.foo = 234
obj.foo = 234
obj.foo = 234
obj.foo = 234
obj.foo = 234
obj.foo = 234
obj.foo = 234
obj.foo = 234
end
end

11
tests/perf/test-prop-write.pl

@ -2,7 +2,16 @@ sub test {
my %obj = ( 'xxx1' => 1, 'xxx2' => 2, 'xxx3' => 3, 'xxx4' => 4, 'foo' => 123 );
my $i;
for ($i = 0; $i < 1e8; $i++) {
for ($i = 0; $i < 1e7; $i++) {
$obj{'foo'} = 234;
$obj{'foo'} = 234;
$obj{'foo'} = 234;
$obj{'foo'} = 234;
$obj{'foo'} = 234;
$obj{'foo'} = 234;
$obj{'foo'} = 234;
$obj{'foo'} = 234;
$obj{'foo'} = 234;
$obj{'foo'} = 234;
}
}

11
tests/perf/test-prop-write.py

@ -1,7 +1,16 @@
def test():
obj = { 'xxx1': 1, 'xxx2': 2, 'xxx3': 4, 'xxx4': 4, 'foo': 123 }
i = 0
while i < 1e8:
while i < 1e7:
obj['foo'] = 234
obj['foo'] = 234
obj['foo'] = 234
obj['foo'] = 234
obj['foo'] = 234
obj['foo'] = 234
obj['foo'] = 234
obj['foo'] = 234
obj['foo'] = 234
obj['foo'] = 234
i += 1

11
tests/perf/test-prop-write.rb

@ -2,7 +2,16 @@ def test()
obj = Hash["xxx1" => 1, "xxx2" => 2, "xxx3" => 3, "xxx4" => 4, "foo" => 123];
i = 0
while i < 1e8 do
while i < 1e7 do
obj['foo'] = 234
obj['foo'] = 234
obj['foo'] = 234
obj['foo'] = 234
obj['foo'] = 234
obj['foo'] = 234
obj['foo'] = 234
obj['foo'] = 234
obj['foo'] = 234
obj['foo'] = 234
i += 1
end

11
tests/perf/test-regexp-string-parse.js

@ -15,7 +15,16 @@ function test() {
var regexpdata = '/' + txt + '/'; // periods will be wildcards
print(regexpdata.length);
for (i = 0; i < 1000; i++) {
for (i = 0; i < 100; i++) {
void new RegExp(regexpdata);
void new RegExp(regexpdata);
void new RegExp(regexpdata);
void new RegExp(regexpdata);
void new RegExp(regexpdata);
void new RegExp(regexpdata);
void new RegExp(regexpdata);
void new RegExp(regexpdata);
void new RegExp(regexpdata);
void new RegExp(regexpdata);
}
}

11
tests/perf/test-regexp-string-parse.py

@ -9,7 +9,16 @@ def test():
regexpdata = '/' + txt + '/'
print(len(regexpdata))
for i in xrange(1000):
for i in xrange(100):
ign = re.compile(regexpdata)
ign = re.compile(regexpdata)
ign = re.compile(regexpdata)
ign = re.compile(regexpdata)
ign = re.compile(regexpdata)
ign = re.compile(regexpdata)
ign = re.compile(regexpdata)
ign = re.compile(regexpdata)
ign = re.compile(regexpdata)
ign = re.compile(regexpdata)
test()

Loading…
Cancel
Save