Skip to content

Commit 4726504

Browse files
committed
typed arrays: preliminary benchmarks
1 parent efcbe3b commit 4726504

3 files changed

Lines changed: 45 additions & 0 deletions

File tree

benchmark/arrays/var_int.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
var types = 'Array Buffer Int8Array Uint8Array Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array'.split(' ');
2+
3+
var type = types[types.indexOf(process.argv[2])];
4+
if (!type)
5+
type = types[0];
6+
7+
console.error('Benchmarking', type);
8+
var clazz = global[type];
9+
10+
var arr = new clazz(25 * 10e5);
11+
for (var i = 0; i < 10; ++i) {
12+
for (var j = 0, k = arr.length; j < k; ++j) {
13+
arr[j] = (j ^ k) & 127;
14+
}
15+
}

benchmark/arrays/zero_float.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
var types = 'Array Buffer Int8Array Uint8Array Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array'.split(' ');
2+
3+
var type = types[types.indexOf(process.argv[2])];
4+
if (!type)
5+
type = types[0];
6+
7+
console.error('Benchmarking', type);
8+
var clazz = global[type];
9+
10+
var arr = new clazz(25 * 10e5);
11+
for (var i = 0; i < 10; ++i) {
12+
for (var j = 0, k = arr.length; j < k; ++j) {
13+
arr[j] = 0.0;
14+
}
15+
}

benchmark/arrays/zero_int.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
var types = 'Array Buffer Int8Array Uint8Array Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array'.split(' ');
2+
3+
var type = types[types.indexOf(process.argv[2])];
4+
if (!type)
5+
type = types[0];
6+
7+
console.error('Benchmarking', type);
8+
var clazz = global[type];
9+
10+
var arr = new clazz(25 * 10e5);
11+
for (var i = 0; i < 10; ++i) {
12+
for (var j = 0, k = arr.length; j < k; ++j) {
13+
arr[j] = 0;
14+
}
15+
}

0 commit comments

Comments
 (0)