From 2ed56e52354d871622e6b9ca5bf44fa7409b511b Mon Sep 17 00:00:00 2001 From: isaacs Date: Tue, 19 Feb 2013 14:59:43 -0800 Subject: bench: Consistency in benchmark filenames --- benchmark/arrays/var-int.js | 20 ++++++++++++ benchmark/arrays/var_int.js | 20 ------------ benchmark/arrays/zero-float.js | 20 ++++++++++++ benchmark/arrays/zero-int.js | 20 ++++++++++++ benchmark/arrays/zero_float.js | 20 ------------ benchmark/arrays/zero_int.js | 20 ------------ benchmark/buffers/buffer-creation.js | 19 +++++++++++ benchmark/buffers/buffer-read.js | 28 ++++++++++++++++ benchmark/buffers/buffer-write.js | 63 ++++++++++++++++++++++++++++++++++++ benchmark/buffers/buffer_creation.js | 19 ----------- benchmark/buffers/buffer_read.js | 28 ---------------- benchmark/buffers/buffer_write.js | 63 ------------------------------------ benchmark/buffers/dataview-set.js | 57 ++++++++++++++++++++++++++++++++ benchmark/buffers/dataview_set.js | 57 -------------------------------- benchmark/http/http_simple.js | 24 -------------- benchmark/http/simple.js | 24 ++++++++++++++ benchmark/misc/string-creation.js | 16 +++++++++ benchmark/misc/string_creation.js | 16 --------- benchmark/misc/v8-bench.js | 18 +++++++++++ benchmark/misc/v8_bench.js | 18 ----------- 20 files changed, 285 insertions(+), 285 deletions(-) create mode 100644 benchmark/arrays/var-int.js delete mode 100644 benchmark/arrays/var_int.js create mode 100644 benchmark/arrays/zero-float.js create mode 100644 benchmark/arrays/zero-int.js delete mode 100644 benchmark/arrays/zero_float.js delete mode 100644 benchmark/arrays/zero_int.js create mode 100644 benchmark/buffers/buffer-creation.js create mode 100644 benchmark/buffers/buffer-read.js create mode 100644 benchmark/buffers/buffer-write.js delete mode 100644 benchmark/buffers/buffer_creation.js delete mode 100644 benchmark/buffers/buffer_read.js delete mode 100644 benchmark/buffers/buffer_write.js create mode 100644 benchmark/buffers/dataview-set.js delete mode 100644 benchmark/buffers/dataview_set.js delete mode 100644 benchmark/http/http_simple.js create mode 100644 benchmark/http/simple.js create mode 100644 benchmark/misc/string-creation.js delete mode 100644 benchmark/misc/string_creation.js create mode 100644 benchmark/misc/v8-bench.js delete mode 100644 benchmark/misc/v8_bench.js (limited to 'benchmark') diff --git a/benchmark/arrays/var-int.js b/benchmark/arrays/var-int.js new file mode 100644 index 000000000..47a7e62dc --- /dev/null +++ b/benchmark/arrays/var-int.js @@ -0,0 +1,20 @@ +var common = require('../common.js'); +var bench = common.createBenchmark(main, { + type: 'Array Buffer Int8Array Uint8Array Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array'.split(' '), + n: [25] +}); + +function main(conf) { + var type = conf.type; + var clazz = global[type]; + var n = +conf.n; + + bench.start(); + var arr = new clazz(n * 1e6); + for (var i = 0; i < 10; ++i) { + for (var j = 0, k = arr.length; j < k; ++j) { + arr[j] = (j ^ k) & 127; + } + } + bench.end(n); +} diff --git a/benchmark/arrays/var_int.js b/benchmark/arrays/var_int.js deleted file mode 100644 index 47a7e62dc..000000000 --- a/benchmark/arrays/var_int.js +++ /dev/null @@ -1,20 +0,0 @@ -var common = require('../common.js'); -var bench = common.createBenchmark(main, { - type: 'Array Buffer Int8Array Uint8Array Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array'.split(' '), - n: [25] -}); - -function main(conf) { - var type = conf.type; - var clazz = global[type]; - var n = +conf.n; - - bench.start(); - var arr = new clazz(n * 1e6); - for (var i = 0; i < 10; ++i) { - for (var j = 0, k = arr.length; j < k; ++j) { - arr[j] = (j ^ k) & 127; - } - } - bench.end(n); -} diff --git a/benchmark/arrays/zero-float.js b/benchmark/arrays/zero-float.js new file mode 100644 index 000000000..a6624205b --- /dev/null +++ b/benchmark/arrays/zero-float.js @@ -0,0 +1,20 @@ +var common = require('../common.js'); +var bench = common.createBenchmark(main, { + type: 'Array Buffer Int8Array Uint8Array Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array'.split(' '), + n: [25] +}); + +function main(conf) { + var type = conf.type; + var clazz = global[type]; + var n = +conf.n; + + bench.start(); + var arr = new clazz(n * 1e6); + for (var i = 0; i < 10; ++i) { + for (var j = 0, k = arr.length; j < k; ++j) { + arr[j] = 0.0; + } + } + bench.end(n); +} diff --git a/benchmark/arrays/zero-int.js b/benchmark/arrays/zero-int.js new file mode 100644 index 000000000..29a2d58b6 --- /dev/null +++ b/benchmark/arrays/zero-int.js @@ -0,0 +1,20 @@ +var common = require('../common.js'); +var bench = common.createBenchmark(main, { + type: 'Array Buffer Int8Array Uint8Array Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array'.split(' '), + n: [25] +}); + +function main(conf) { + var type = conf.type; + var clazz = global[type]; + var n = +conf.n; + + bench.start(); + var arr = new clazz(n * 1e6); + for (var i = 0; i < 10; ++i) { + for (var j = 0, k = arr.length; j < k; ++j) { + arr[j] = 0; + } + } + bench.end(n); +} diff --git a/benchmark/arrays/zero_float.js b/benchmark/arrays/zero_float.js deleted file mode 100644 index a6624205b..000000000 --- a/benchmark/arrays/zero_float.js +++ /dev/null @@ -1,20 +0,0 @@ -var common = require('../common.js'); -var bench = common.createBenchmark(main, { - type: 'Array Buffer Int8Array Uint8Array Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array'.split(' '), - n: [25] -}); - -function main(conf) { - var type = conf.type; - var clazz = global[type]; - var n = +conf.n; - - bench.start(); - var arr = new clazz(n * 1e6); - for (var i = 0; i < 10; ++i) { - for (var j = 0, k = arr.length; j < k; ++j) { - arr[j] = 0.0; - } - } - bench.end(n); -} diff --git a/benchmark/arrays/zero_int.js b/benchmark/arrays/zero_int.js deleted file mode 100644 index 29a2d58b6..000000000 --- a/benchmark/arrays/zero_int.js +++ /dev/null @@ -1,20 +0,0 @@ -var common = require('../common.js'); -var bench = common.createBenchmark(main, { - type: 'Array Buffer Int8Array Uint8Array Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array'.split(' '), - n: [25] -}); - -function main(conf) { - var type = conf.type; - var clazz = global[type]; - var n = +conf.n; - - bench.start(); - var arr = new clazz(n * 1e6); - for (var i = 0; i < 10; ++i) { - for (var j = 0, k = arr.length; j < k; ++j) { - arr[j] = 0; - } - } - bench.end(n); -} diff --git a/benchmark/buffers/buffer-creation.js b/benchmark/buffers/buffer-creation.js new file mode 100644 index 000000000..bc0c55711 --- /dev/null +++ b/benchmark/buffers/buffer-creation.js @@ -0,0 +1,19 @@ +SlowBuffer = require('buffer').SlowBuffer; + +var common = require('../common.js'); +var bench = common.createBenchmark(main, { + type: ['fast', 'slow'], + len: [10, 1024], + n: [1024] +}); + +function main(conf) { + var len = +conf.len; + var n = +conf.n; + var clazz = conf.type === 'fast' ? Buffer : SlowBuffer; + bench.start(); + for (var i = 0; i < n * 1024; i++) { + b = new clazz(len); + } + bench.end(n); +} diff --git a/benchmark/buffers/buffer-read.js b/benchmark/buffers/buffer-read.js new file mode 100644 index 000000000..fccd99dcd --- /dev/null +++ b/benchmark/buffers/buffer-read.js @@ -0,0 +1,28 @@ +var common = require('../common.js'); + +var bench = common.createBenchmark(main, { + noAssert: [false, true], + buffer: ['fast', 'slow'], + type: ['UInt8', 'UInt16LE', 'UInt16BE', + 'UInt32LE', 'UInt32BE', + 'Int8', 'Int16LE', 'Int16BE', + 'Int32LE', 'Int32BE', + 'FloatLE', 'FloatBE', + 'DoubleLE', 'DoubleBE'], + millions: [1] +}); + +function main(conf) { + var noAssert = conf.noAssert === 'true'; + var len = +conf.millions * 1e6; + var clazz = conf.buf === 'fast' ? Buffer : require('buffer').SlowBuffer; + var buff = new clazz(8); + var fn = 'read' + conf.type; + + buff.writeDoubleLE(0, 0, noAssert); + bench.start(); + for (var i = 0; i < len; i++) { + buff[fn](0, noAssert); + } + bench.end(len / 1e6); +} diff --git a/benchmark/buffers/buffer-write.js b/benchmark/buffers/buffer-write.js new file mode 100644 index 000000000..4dbfcb609 --- /dev/null +++ b/benchmark/buffers/buffer-write.js @@ -0,0 +1,63 @@ + +var common = require('../common.js'); +var bench = common.createBenchmark(main, { + noAssert: [false, true], + buffer: ['fast', 'slow'], + type: ['UInt8', 'UInt16LE', 'UInt16BE', + 'UInt32LE', 'UInt32BE', + 'Int8', 'Int16LE', 'Int16BE', + 'Int32LE', 'Int32BE', + 'FloatLE', 'FloatBE', + 'DoubleLE', 'DoubleBE'], + millions: [1] +}); + +const INT8 = 0x7f; +const INT16 = 0x7fff; +const INT32 = 0x7fffffff; +const UINT8 = INT8 * 2; +const UINT16 = INT16 * 2; +const UINT32 = INT32 * 2; + +var mod = { + writeInt8: INT8, + writeInt16BE: INT16, + writeInt16LE: INT16, + writeInt32BE: INT32, + writeInt32LE: INT32, + writeUInt8: UINT8, + writeUInt16BE: UINT16, + writeUInt16LE: UINT16, + writeUInt32BE: UINT32, + writeUInt32LE: UINT32 +}; + +function main(conf) { + var noAssert = conf.noAssert === 'true'; + var len = +conf.millions * 1e6; + var clazz = conf.buf === 'fast' ? Buffer : require('buffer').SlowBuffer; + var buff = new clazz(8); + var fn = 'write' + conf.type; + + if (fn.match(/Int/)) + benchInt(buff, fn, len, noAssert); + else + benchFloat(buff, fn, len, noAssert); +} + +function benchInt(buff, fn, len, noAssert) { + var m = mod[fn]; + bench.start(); + for (var i = 0; i < len; i++) { + buff[fn](i % m, 0, noAssert); + } + bench.end(len / 1e6); +} + +function benchFloat(buff, fn, len, noAssert) { + bench.start(); + for (var i = 0; i < len; i++) { + buff[fn](i * 0.1, 0, noAssert); + } + bench.end(len / 1e6); +} diff --git a/benchmark/buffers/buffer_creation.js b/benchmark/buffers/buffer_creation.js deleted file mode 100644 index bc0c55711..000000000 --- a/benchmark/buffers/buffer_creation.js +++ /dev/null @@ -1,19 +0,0 @@ -SlowBuffer = require('buffer').SlowBuffer; - -var common = require('../common.js'); -var bench = common.createBenchmark(main, { - type: ['fast', 'slow'], - len: [10, 1024], - n: [1024] -}); - -function main(conf) { - var len = +conf.len; - var n = +conf.n; - var clazz = conf.type === 'fast' ? Buffer : SlowBuffer; - bench.start(); - for (var i = 0; i < n * 1024; i++) { - b = new clazz(len); - } - bench.end(n); -} diff --git a/benchmark/buffers/buffer_read.js b/benchmark/buffers/buffer_read.js deleted file mode 100644 index fccd99dcd..000000000 --- a/benchmark/buffers/buffer_read.js +++ /dev/null @@ -1,28 +0,0 @@ -var common = require('../common.js'); - -var bench = common.createBenchmark(main, { - noAssert: [false, true], - buffer: ['fast', 'slow'], - type: ['UInt8', 'UInt16LE', 'UInt16BE', - 'UInt32LE', 'UInt32BE', - 'Int8', 'Int16LE', 'Int16BE', - 'Int32LE', 'Int32BE', - 'FloatLE', 'FloatBE', - 'DoubleLE', 'DoubleBE'], - millions: [1] -}); - -function main(conf) { - var noAssert = conf.noAssert === 'true'; - var len = +conf.millions * 1e6; - var clazz = conf.buf === 'fast' ? Buffer : require('buffer').SlowBuffer; - var buff = new clazz(8); - var fn = 'read' + conf.type; - - buff.writeDoubleLE(0, 0, noAssert); - bench.start(); - for (var i = 0; i < len; i++) { - buff[fn](0, noAssert); - } - bench.end(len / 1e6); -} diff --git a/benchmark/buffers/buffer_write.js b/benchmark/buffers/buffer_write.js deleted file mode 100644 index 4dbfcb609..000000000 --- a/benchmark/buffers/buffer_write.js +++ /dev/null @@ -1,63 +0,0 @@ - -var common = require('../common.js'); -var bench = common.createBenchmark(main, { - noAssert: [false, true], - buffer: ['fast', 'slow'], - type: ['UInt8', 'UInt16LE', 'UInt16BE', - 'UInt32LE', 'UInt32BE', - 'Int8', 'Int16LE', 'Int16BE', - 'Int32LE', 'Int32BE', - 'FloatLE', 'FloatBE', - 'DoubleLE', 'DoubleBE'], - millions: [1] -}); - -const INT8 = 0x7f; -const INT16 = 0x7fff; -const INT32 = 0x7fffffff; -const UINT8 = INT8 * 2; -const UINT16 = INT16 * 2; -const UINT32 = INT32 * 2; - -var mod = { - writeInt8: INT8, - writeInt16BE: INT16, - writeInt16LE: INT16, - writeInt32BE: INT32, - writeInt32LE: INT32, - writeUInt8: UINT8, - writeUInt16BE: UINT16, - writeUInt16LE: UINT16, - writeUInt32BE: UINT32, - writeUInt32LE: UINT32 -}; - -function main(conf) { - var noAssert = conf.noAssert === 'true'; - var len = +conf.millions * 1e6; - var clazz = conf.buf === 'fast' ? Buffer : require('buffer').SlowBuffer; - var buff = new clazz(8); - var fn = 'write' + conf.type; - - if (fn.match(/Int/)) - benchInt(buff, fn, len, noAssert); - else - benchFloat(buff, fn, len, noAssert); -} - -function benchInt(buff, fn, len, noAssert) { - var m = mod[fn]; - bench.start(); - for (var i = 0; i < len; i++) { - buff[fn](i % m, 0, noAssert); - } - bench.end(len / 1e6); -} - -function benchFloat(buff, fn, len, noAssert) { - bench.start(); - for (var i = 0; i < len; i++) { - buff[fn](i * 0.1, 0, noAssert); - } - bench.end(len / 1e6); -} diff --git a/benchmark/buffers/dataview-set.js b/benchmark/buffers/dataview-set.js new file mode 100644 index 000000000..ce0064edb --- /dev/null +++ b/benchmark/buffers/dataview-set.js @@ -0,0 +1,57 @@ + +var common = require('../common.js'); +var bench = common.createBenchmark(main, { + type: ['Uint8', 'Uint16LE', 'Uint16BE', + 'Uint32LE', 'Uint32BE', + 'Int8', 'Int16LE', 'Int16BE', + 'Int32LE', 'Int32BE', + 'Float32LE', 'Float32BE', + 'Float64LE', 'Float64BE'], + millions: [1] +}); + +const INT8 = 0x7f; +const INT16 = 0x7fff; +const INT32 = 0x7fffffff; +const UINT8 = INT8 * 2; +const UINT16 = INT16 * 2; +const UINT32 = INT32 * 2; + +var mod = { + setInt8: INT8, + setInt16: INT16, + setInt32: INT32, + setUint8: UINT8, + setUint16: UINT16, + setUint32: UINT32 +}; + +function main(conf) { + var len = +conf.millions * 1e6; + var ab = new ArrayBuffer(8); + var dv = new DataView(ab, 0, 8); + var le = /LE$/.test(conf.type); + var fn = 'set' + conf.type.replace(/[LB]E$/, ''); + + if (/int/i.test(fn)) + benchInt(dv, fn, len, le); + else + benchFloat(dv, fn, len, le); +} + +function benchInt(dv, fn, len, le) { + var m = mod[fn]; + bench.start(); + for (var i = 0; i < len; i++) { + dv[fn](0, i % m, le); + } + bench.end(len / 1e6); +} + +function benchFloat(dv, fn, len, le) { + bench.start(); + for (var i = 0; i < len; i++) { + dv[fn](0, i * 0.1, le); + } + bench.end(len / 1e6); +} diff --git a/benchmark/buffers/dataview_set.js b/benchmark/buffers/dataview_set.js deleted file mode 100644 index ce0064edb..000000000 --- a/benchmark/buffers/dataview_set.js +++ /dev/null @@ -1,57 +0,0 @@ - -var common = require('../common.js'); -var bench = common.createBenchmark(main, { - type: ['Uint8', 'Uint16LE', 'Uint16BE', - 'Uint32LE', 'Uint32BE', - 'Int8', 'Int16LE', 'Int16BE', - 'Int32LE', 'Int32BE', - 'Float32LE', 'Float32BE', - 'Float64LE', 'Float64BE'], - millions: [1] -}); - -const INT8 = 0x7f; -const INT16 = 0x7fff; -const INT32 = 0x7fffffff; -const UINT8 = INT8 * 2; -const UINT16 = INT16 * 2; -const UINT32 = INT32 * 2; - -var mod = { - setInt8: INT8, - setInt16: INT16, - setInt32: INT32, - setUint8: UINT8, - setUint16: UINT16, - setUint32: UINT32 -}; - -function main(conf) { - var len = +conf.millions * 1e6; - var ab = new ArrayBuffer(8); - var dv = new DataView(ab, 0, 8); - var le = /LE$/.test(conf.type); - var fn = 'set' + conf.type.replace(/[LB]E$/, ''); - - if (/int/i.test(fn)) - benchInt(dv, fn, len, le); - else - benchFloat(dv, fn, len, le); -} - -function benchInt(dv, fn, len, le) { - var m = mod[fn]; - bench.start(); - for (var i = 0; i < len; i++) { - dv[fn](0, i % m, le); - } - bench.end(len / 1e6); -} - -function benchFloat(dv, fn, len, le) { - bench.start(); - for (var i = 0; i < len; i++) { - dv[fn](0, i * 0.1, le); - } - bench.end(len / 1e6); -} diff --git a/benchmark/http/http_simple.js b/benchmark/http/http_simple.js deleted file mode 100644 index 04a2a2911..000000000 --- a/benchmark/http/http_simple.js +++ /dev/null @@ -1,24 +0,0 @@ -var common = require('../common.js'); -var PORT = common.PORT; - -var bench = common.createBenchmark(main, { - // unicode confuses ab on os x. - type: ['bytes', 'buffer'], - length: [4, 1024, 102400], - c: [50, 500] -}); - -function main(conf) { - process.env.PORT = PORT; - var spawn = require('child_process').spawn; - var simple = require('path').resolve(__dirname, '../http_simple.js'); - var server = spawn(process.execPath, [simple]); - setTimeout(function() { - var path = '/' + conf.type + '/' + conf.length; //+ '/' + conf.chunks; - var args = ['-r', 5000, '-t', 8, '-c', conf.c]; - - bench.http(path, args, function() { - server.kill(); - }); - }, 2000); -} diff --git a/benchmark/http/simple.js b/benchmark/http/simple.js new file mode 100644 index 000000000..04a2a2911 --- /dev/null +++ b/benchmark/http/simple.js @@ -0,0 +1,24 @@ +var common = require('../common.js'); +var PORT = common.PORT; + +var bench = common.createBenchmark(main, { + // unicode confuses ab on os x. + type: ['bytes', 'buffer'], + length: [4, 1024, 102400], + c: [50, 500] +}); + +function main(conf) { + process.env.PORT = PORT; + var spawn = require('child_process').spawn; + var simple = require('path').resolve(__dirname, '../http_simple.js'); + var server = spawn(process.execPath, [simple]); + setTimeout(function() { + var path = '/' + conf.type + '/' + conf.length; //+ '/' + conf.chunks; + var args = ['-r', 5000, '-t', 8, '-c', conf.c]; + + bench.http(path, args, function() { + server.kill(); + }); + }, 2000); +} diff --git a/benchmark/misc/string-creation.js b/benchmark/misc/string-creation.js new file mode 100644 index 000000000..74dabd66c --- /dev/null +++ b/benchmark/misc/string-creation.js @@ -0,0 +1,16 @@ + +var common = require('../common.js'); +var bench = common.createBenchmark(main, { + millions: [100] +}) + +function main(conf) { + var n = +conf.millions * 1e6; + bench.start(); + var s; + for (var i = 0; i < n; i++) { + s = '01234567890'; + s[1] = "a"; + } + bench.end(n / 1e6); +} diff --git a/benchmark/misc/string_creation.js b/benchmark/misc/string_creation.js deleted file mode 100644 index 74dabd66c..000000000 --- a/benchmark/misc/string_creation.js +++ /dev/null @@ -1,16 +0,0 @@ - -var common = require('../common.js'); -var bench = common.createBenchmark(main, { - millions: [100] -}) - -function main(conf) { - var n = +conf.millions * 1e6; - bench.start(); - var s; - for (var i = 0; i < n; i++) { - s = '01234567890'; - s[1] = "a"; - } - bench.end(n / 1e6); -} diff --git a/benchmark/misc/v8-bench.js b/benchmark/misc/v8-bench.js new file mode 100644 index 000000000..8bf49f3f6 --- /dev/null +++ b/benchmark/misc/v8-bench.js @@ -0,0 +1,18 @@ +// compare with "google-chrome deps/v8/benchmarks/run.html" +var fs = require('fs'); +var path = require('path'); +var vm = require('vm'); + +var dir = path.join(__dirname, '..', '..', 'deps', 'v8', 'benchmarks'); + +global.print = function(s) { + if (s === '----') return; + console.log('misc/v8_bench.js %s', s); +}; + +global.load = function (x) { + var source = fs.readFileSync(path.join(dir, x), 'utf8'); + vm.runInThisContext(source, x); +} + +load('run.js'); diff --git a/benchmark/misc/v8_bench.js b/benchmark/misc/v8_bench.js deleted file mode 100644 index 8bf49f3f6..000000000 --- a/benchmark/misc/v8_bench.js +++ /dev/null @@ -1,18 +0,0 @@ -// compare with "google-chrome deps/v8/benchmarks/run.html" -var fs = require('fs'); -var path = require('path'); -var vm = require('vm'); - -var dir = path.join(__dirname, '..', '..', 'deps', 'v8', 'benchmarks'); - -global.print = function(s) { - if (s === '----') return; - console.log('misc/v8_bench.js %s', s); -}; - -global.load = function (x) { - var source = fs.readFileSync(path.join(dir, x), 'utf8'); - vm.runInThisContext(source, x); -} - -load('run.js'); -- cgit v1.2.3