Skip to content
Permalink
Browse files

benchmark: use strict mode

Apply strict mode to benchmark code.

PR-URL: #5336
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
  • Loading branch information...
Trott authored and rvagg committed Feb 20, 2016
1 parent 0f54553 commit 2f9fee6e8e8d7608d2648c6132836f3f9d1d1947
Showing with 105 additions and 14 deletions.
  1. +1 −0 benchmark/arrays/var-int.js
  2. +1 −0 benchmark/arrays/zero-float.js
  3. +1 −0 benchmark/arrays/zero-int.js
  4. +1 −0 benchmark/buffers/buffer-base64-decode.js
  5. +1 −0 benchmark/buffers/buffer-base64-encode.js
  6. +1 −0 benchmark/buffers/buffer-bytelength.js
  7. +1 −0 benchmark/buffers/buffer-compare.js
  8. +2 −1 benchmark/buffers/buffer-creation.js
  9. +1 −0 benchmark/buffers/buffer-indexof.js
  10. +1 −0 benchmark/buffers/buffer-iterate.js
  11. +1 −0 benchmark/buffers/buffer-read.js
  12. +1 −0 benchmark/buffers/buffer-slice.js
  13. +1 −1 benchmark/buffers/buffer-write.js
  14. +1 −1 benchmark/buffers/dataview-set.js
  15. +1 −0 benchmark/common.js
  16. +4 −3 benchmark/compare.js
  17. +1 −0 benchmark/crypto/aes-gcm-throughput.js
  18. +1 −0 benchmark/crypto/cipher-stream.js
  19. +1 −0 benchmark/crypto/hash-stream-creation.js
  20. +1 −0 benchmark/crypto/hash-stream-throughput.js
  21. +1 −0 benchmark/crypto/rsa-encrypt-decrypt-throughput.js
  22. +1 −0 benchmark/crypto/rsa-sign-verify-throughput.js
  23. +1 −0 benchmark/events/ee-add-remove.js
  24. +1 −0 benchmark/events/ee-emit-multi-args.js
  25. +1 −0 benchmark/events/ee-emit.js
  26. +1 −0 benchmark/events/ee-listener-count-on-prototype.js
  27. +1 −0 benchmark/events/ee-listeners-many.js
  28. +1 −0 benchmark/events/ee-listeners.js
  29. +1 −1 benchmark/fs-write-stream-throughput.js
  30. +1 −0 benchmark/fs/read-stream-throughput.js
  31. +1 −0 benchmark/fs/readfile.js
  32. +1 −0 benchmark/fs/write-stream-throughput.js
  33. +2 −1 benchmark/http/chunked.js
  34. +1 −0 benchmark/http/client-request-body.js
  35. +1 −0 benchmark/http/cluster.js
  36. +2 −2 benchmark/http/end-vs-write-end.js
  37. +1 −0 benchmark/http/simple.js
  38. +1 −0 benchmark/http_bench.js
  39. +2 −0 benchmark/http_server_lag.js
  40. +2 −0 benchmark/http_simple.js
  41. +1 −0 benchmark/http_simple_auto.js
  42. +1 −0 benchmark/http_simple_cluster.js
  43. +2 −1 benchmark/idle_clients.js
  44. +1 −0 benchmark/misc/child-process-read.js
  45. +4 −3 benchmark/misc/domain-fn-args.js
  46. +1 −0 benchmark/misc/function_call/index.js
  47. +1 −0 benchmark/misc/module-loader.js
  48. +1 −0 benchmark/misc/next-tick-breadth.js
  49. +1 −0 benchmark/misc/next-tick-depth.js
  50. +1 −0 benchmark/misc/spawn-echo.js
  51. +1 −0 benchmark/misc/startup.js
  52. +1 −0 benchmark/misc/string-creation.js
  53. +1 −0 benchmark/misc/string-decoder.js
  54. +1 −0 benchmark/misc/timers.js
  55. +1 −0 benchmark/misc/url.js
  56. +1 −0 benchmark/misc/v8-bench.js
  57. +1 −0 benchmark/net/net-c2s-cork.js
  58. +1 −0 benchmark/net/net-c2s.js
  59. +1 −0 benchmark/net/net-pipe.js
  60. +1 −0 benchmark/net/net-s2c.js
  61. +1 −0 benchmark/net/tcp-raw-c2s.js
  62. +1 −0 benchmark/net/tcp-raw-pipe.js
  63. +1 −0 benchmark/net/tcp-raw-s2c.js
  64. +1 −0 benchmark/path/basename-posix.js
  65. +1 −0 benchmark/path/basename-win32.js
  66. +1 −0 benchmark/path/dirname-posix.js
  67. +1 −0 benchmark/path/dirname-win32.js
  68. +1 −0 benchmark/path/extname-posix.js
  69. +1 −0 benchmark/path/extname-win32.js
  70. +1 −0 benchmark/path/format-posix.js
  71. +1 −0 benchmark/path/format-win32.js
  72. +1 −0 benchmark/path/isAbsolute-posix.js
  73. +1 −0 benchmark/path/isAbsolute-win32.js
  74. +1 −0 benchmark/path/join-posix.js
  75. +1 −0 benchmark/path/join-win32.js
  76. +1 −0 benchmark/path/makeLong-win32.js
  77. +1 −0 benchmark/path/normalize-posix.js
  78. +1 −0 benchmark/path/normalize-win32.js
  79. +1 −0 benchmark/path/parse-posix.js
  80. +1 −0 benchmark/path/parse-win32.js
  81. +1 −0 benchmark/path/relative-posix.js
  82. +1 −0 benchmark/path/relative-win32.js
  83. +1 −0 benchmark/path/resolve-posix.js
  84. +1 −0 benchmark/path/resolve-win32.js
  85. +1 −0 benchmark/querystring/querystring-parse.js
  86. +1 −0 benchmark/querystring/querystring-stringify.js
  87. +1 −0 benchmark/report-startup-memory.js
  88. +1 −0 benchmark/static_http_server.js
  89. +1 −0 benchmark/tls/throughput.js
  90. +1 −0 benchmark/tls/tls-connect.js
  91. +1 −0 benchmark/url/url-parse.js
  92. +1 −0 benchmark/url/url-resolve.js
  93. +1 −0 benchmark/util/inspect.js
@@ -1,3 +1,4 @@
'use strict';
var common = require('../common.js');
var bench = common.createBenchmark(main, {
type: 'Array Buffer Int8Array Uint8Array Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array'.split(' '),
@@ -1,3 +1,4 @@
'use strict';
var common = require('../common.js');
var bench = common.createBenchmark(main, {
type: 'Array Buffer Int8Array Uint8Array Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array'.split(' '),
@@ -1,3 +1,4 @@
'use strict';
var common = require('../common.js');
var bench = common.createBenchmark(main, {
type: 'Array Buffer Int8Array Uint8Array Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array'.split(' '),
@@ -1,3 +1,4 @@
'use strict';
var assert = require('assert');
var common = require('../common.js');

@@ -1,3 +1,4 @@
'use strict';
var common = require('../common.js');

var bench = common.createBenchmark(main, {});
@@ -1,3 +1,4 @@
'use strict';
var common = require('../common');

var bench = common.createBenchmark(main, {
@@ -1,3 +1,4 @@
'use strict';
var common = require('../common.js');

var bench = common.createBenchmark(main, {
@@ -1,4 +1,5 @@
SlowBuffer = require('buffer').SlowBuffer;
'use strict';
const SlowBuffer = require('buffer').SlowBuffer;

var common = require('../common.js');
var bench = common.createBenchmark(main, {
@@ -1,3 +1,4 @@
'use strict';
var common = require('../common.js');
var fs = require('fs');

@@ -1,3 +1,4 @@
'use strict';
var SlowBuffer = require('buffer').SlowBuffer;
var common = require('../common.js');
var assert = require('assert');
@@ -1,3 +1,4 @@
'use strict';
var common = require('../common.js');

var bench = common.createBenchmark(main, {
@@ -1,3 +1,4 @@
'use strict';
var common = require('../common.js');
var SlowBuffer = require('buffer').SlowBuffer;

@@ -1,4 +1,4 @@

'use strict';
var common = require('../common.js');
var bench = common.createBenchmark(main, {
noAssert: [false, true],
@@ -1,4 +1,4 @@

'use strict';
var common = require('../common.js');
var bench = common.createBenchmark(main, {
type: ['Uint8', 'Uint16LE', 'Uint16BE',
@@ -1,3 +1,4 @@
'use strict';
var assert = require('assert');
var fs = require('fs');
var path = require('path');
@@ -1,3 +1,4 @@
'use strict';
var usage = 'node benchmark/compare.js ' +
'<node-binary1> <node-binary2> ' +
'[--html] [--red|-r] [--green|-g] ' +
@@ -38,9 +39,9 @@ for (var i = 2; i < process.argv.length; i++) {

if (!html) {
var start = '';
var green = '\033[1;32m';
var red = '\033[1;31m';
var reset = '\033[m';
var green = '\u001b[1;32m';
var red = '\u001b[1;31m';
var reset = '\u001b[m';
var end = '';
} else {
var start = '<pre style="background-color:#333;color:#eee">';
@@ -1,3 +1,4 @@
'use strict';
var common = require('../common.js');
var crypto = require('crypto');
var keylen = {'aes-128-gcm': 16, 'aes-192-gcm': 24, 'aes-256-gcm': 32};
@@ -1,3 +1,4 @@
'use strict';
var common = require('../common.js');

var bench = common.createBenchmark(main, {
@@ -1,5 +1,6 @@
// throughput benchmark
// creates a single hasher, then pushes a bunch of data through it
'use strict';
var common = require('../common.js');
var crypto = require('crypto');

@@ -1,5 +1,6 @@
// throughput benchmark
// creates a single hasher, then pushes a bunch of data through it
'use strict';
var common = require('../common.js');
var crypto = require('crypto');

@@ -1,3 +1,4 @@
'use strict';
// throughput benchmark in signing and verifying
var common = require('../common.js');
var crypto = require('crypto');
@@ -1,3 +1,4 @@
'use strict';
// throughput benchmark in signing and verifying
var common = require('../common.js');
var crypto = require('crypto');
@@ -1,3 +1,4 @@
'use strict';
var common = require('../common.js');
var events = require('events');

@@ -1,3 +1,4 @@
'use strict';
var common = require('../common.js');
var EventEmitter = require('events').EventEmitter;

@@ -1,3 +1,4 @@
'use strict';
var common = require('../common.js');
var EventEmitter = require('events').EventEmitter;

@@ -1,3 +1,4 @@
'use strict';
var common = require('../common.js');
var EventEmitter = require('events').EventEmitter;

@@ -1,3 +1,4 @@
'use strict';
var common = require('../common.js');
var EventEmitter = require('events').EventEmitter;

@@ -1,3 +1,4 @@
'use strict';
var common = require('../common.js');
var EventEmitter = require('events').EventEmitter;

@@ -1,5 +1,5 @@

// If there are no args, then this is the root. Run all the benchmarks!
'use strict';
if (!process.argv[2])
parent();
else
@@ -1,4 +1,5 @@
// test the throughput of the fs.WriteStream class.
'use strict';

var path = require('path');
var common = require('../common.js');
@@ -1,6 +1,7 @@
// Call fs.readFile over and over again really fast.
// Then see how many times it got called.
// Yes, this is a silly benchmark. Most benchmarks are silly.
'use strict';

var path = require('path');
var common = require('../common.js');
@@ -1,4 +1,5 @@
// test the throughput of the fs.WriteStream class.
'use strict';

var path = require('path');
var common = require('../common.js');
@@ -6,6 +6,7 @@
// always as hot as it could be.
//
// Verify that our assumptions are valid.
'use strict';

var common = require('../common.js');
var PORT = common.PORT;
@@ -17,7 +18,7 @@ var bench = common.createBenchmark(main, {
});

function main(conf) {
http = require('http');
const http = require('http');
var chunk = new Buffer(conf.size);
chunk.fill('8');

@@ -1,4 +1,5 @@
// Measure the time it takes for the HTTP client to send a request body.
'use strict';

var common = require('../common.js');
var http = require('http');
@@ -1,3 +1,4 @@
'use strict';
var common = require('../common.js');
var PORT = common.PORT;

@@ -6,6 +6,7 @@
// always as hot as it could be.
//
// Verify that our assumptions are valid.
'use strict';

var common = require('../common.js');
var PORT = common.PORT;
@@ -18,7 +19,7 @@ var bench = common.createBenchmark(main, {
});

function main(conf) {
http = require('http');
const http = require('http');
var chunk;
var len = conf.kb * 1024;
switch (conf.type) {
@@ -27,7 +28,6 @@ function main(conf) {
chunk.fill('x');
break;
case 'utf':
encoding = 'utf8';
chunk = new Array(len / 2 + 1).join('ü');
break;
case 'asc':
@@ -1,3 +1,4 @@
'use strict';
var common = require('../common.js');
var PORT = common.PORT;

@@ -1,3 +1,4 @@
'use strict';
var spawn = require('child_process').spawn;
var cluster = require('cluster');
var http = require('http');
@@ -1,3 +1,5 @@
'use strict';

var http = require('http');
var port = parseInt(process.env.PORT, 10) || 8000;
var defaultLag = parseInt(process.argv[2], 10) || 100;
@@ -1,3 +1,5 @@
'use strict';

var path = require('path'),
exec = require('child_process').exec,
http = require('http');
@@ -6,6 +6,7 @@
// <args> Arguments to pass to `ab`.
// <target> Target to benchmark, e.g. `bytes/1024` or `buffer/8192`.
//
'use strict';

var path = require("path");
var http = require("http");
@@ -1,3 +1,4 @@
'use strict';
var cluster = require('cluster');
var os = require('os');

@@ -1,4 +1,5 @@
net = require('net');
'use strict';
const net = require('net');

var errors = 0, connections = 0;

@@ -1,3 +1,4 @@
'use strict';
var common = require('../common.js');
var bench = common.createBenchmark(main, {
len: [64, 256, 1024, 4096, 32768],
@@ -1,3 +1,4 @@
'use strict';
var common = require('../common.js');
var domain = require('domain');

@@ -12,13 +13,13 @@ var gargs = [1, 2, 3];
function main(conf) {

var args, ret, n = +conf.n;
var arguments = gargs.slice(0, conf.arguments);
var myArguments = gargs.slice(0, conf.arguments);
bench.start();

bdomain.enter();
for (var i = 0; i < n; i++) {
if (arguments.length >= 2) {
args = Array.prototype.slice.call(arguments, 1);
if (myArguments.length >= 2) {
args = Array.prototype.slice.call(myArguments, 1);
ret = fn.apply(this, args);
} else {
ret = fn.call(this);
@@ -2,6 +2,7 @@
// relative to a comparable C++ function.
// Reports millions of calls per second.
// Note that JS speed goes up, while cxx speed stays about the same.
'use strict';

var assert = require('assert');
var common = require('../../common.js');
@@ -1,3 +1,4 @@
'use strict';
var fs = require('fs');
var path = require('path');
var common = require('../common.js');
@@ -1,3 +1,4 @@
'use strict';

var common = require('../common.js');
var bench = common.createBenchmark(main, {
@@ -1,3 +1,4 @@
'use strict';
var common = require('../common.js');
var bench = common.createBenchmark(main, {
millions: [2]
@@ -1,3 +1,4 @@
'use strict';
var common = require('../common.js');
var bench = common.createBenchmark(main, {
thousands: [1]
@@ -1,3 +1,4 @@
'use strict';
var common = require('../common.js');
var spawn = require('child_process').spawn;
var path = require('path');
@@ -1,3 +1,4 @@
'use strict';

var common = require('../common.js');
var bench = common.createBenchmark(main, {
@@ -1,3 +1,4 @@
'use strict';
var common = require('../common.js');
var StringDecoder = require('string_decoder').StringDecoder;

@@ -1,3 +1,4 @@
'use strict';
var common = require('../common.js');

var bench = common.createBenchmark(main, {
@@ -1,3 +1,4 @@
'use strict';
var url = require('url')
var n = 25 * 100;

@@ -1,4 +1,5 @@
// compare with "google-chrome deps/v8/benchmarks/run.html"
'use strict';
var fs = require('fs');
var path = require('path');
var vm = require('vm');
@@ -1,4 +1,5 @@
// test the speed of .pipe() with sockets
'use strict';

var common = require('../common.js');
var PORT = common.PORT;
@@ -1,4 +1,5 @@
// test the speed of .pipe() with sockets
'use strict';

var common = require('../common.js');
var PORT = common.PORT;
@@ -1,4 +1,5 @@
// test the speed of .pipe() with sockets
'use strict';

var common = require('../common.js');
var PORT = common.PORT;
@@ -1,4 +1,5 @@
// test the speed of .pipe() with sockets
'use strict';

var common = require('../common.js');
var PORT = common.PORT;
@@ -1,5 +1,6 @@
// In this benchmark, we connect a client to the server, and write
// as many bytes as we can in the specified time (default = 10s)
'use strict';

var common = require('../common.js');
var util = require('util');

0 comments on commit 2f9fee6

Please sign in to comment.
You can’t perform that action at this time.