From 47265046632a64fcd2f7c9e50e3c2caa598f51e7 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 27 Jul 2011 05:08:47 +0200 Subject: [PATCH] typed arrays: preliminary benchmarks --- benchmark/arrays/var_int.js | 15 +++++++++++++++ benchmark/arrays/zero_float.js | 15 +++++++++++++++ benchmark/arrays/zero_int.js | 15 +++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 benchmark/arrays/var_int.js create mode 100644 benchmark/arrays/zero_float.js create mode 100644 benchmark/arrays/zero_int.js diff --git a/benchmark/arrays/var_int.js b/benchmark/arrays/var_int.js new file mode 100644 index 00000000000..17e12989f5e --- /dev/null +++ b/benchmark/arrays/var_int.js @@ -0,0 +1,15 @@ +var types = 'Array Buffer Int8Array Uint8Array Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array'.split(' '); + +var type = types[types.indexOf(process.argv[2])]; +if (!type) + type = types[0]; + +console.error('Benchmarking', type); +var clazz = global[type]; + +var arr = new clazz(25 * 10e5); +for (var i = 0; i < 10; ++i) { + for (var j = 0, k = arr.length; j < k; ++j) { + arr[j] = (j ^ k) & 127; + } +} diff --git a/benchmark/arrays/zero_float.js b/benchmark/arrays/zero_float.js new file mode 100644 index 00000000000..bdb8765d0a4 --- /dev/null +++ b/benchmark/arrays/zero_float.js @@ -0,0 +1,15 @@ +var types = 'Array Buffer Int8Array Uint8Array Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array'.split(' '); + +var type = types[types.indexOf(process.argv[2])]; +if (!type) + type = types[0]; + +console.error('Benchmarking', type); +var clazz = global[type]; + +var arr = new clazz(25 * 10e5); +for (var i = 0; i < 10; ++i) { + for (var j = 0, k = arr.length; j < k; ++j) { + arr[j] = 0.0; + } +} diff --git a/benchmark/arrays/zero_int.js b/benchmark/arrays/zero_int.js new file mode 100644 index 00000000000..17dac62c147 --- /dev/null +++ b/benchmark/arrays/zero_int.js @@ -0,0 +1,15 @@ +var types = 'Array Buffer Int8Array Uint8Array Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array'.split(' '); + +var type = types[types.indexOf(process.argv[2])]; +if (!type) + type = types[0]; + +console.error('Benchmarking', type); +var clazz = global[type]; + +var arr = new clazz(25 * 10e5); +for (var i = 0; i < 10; ++i) { + for (var j = 0, k = arr.length; j < k; ++j) { + arr[j] = 0; + } +}