Skip to content

Commit 4bb529d

Browse files
committed
benchmark: use strict mode
Apply strict mode to benchmark code. PR-URL: #5336 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 65cd2a0 commit 4bb529d

File tree

93 files changed

+105
-14
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+105
-14
lines changed

benchmark/arrays/var-int.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
var common = require('../common.js');
23
var bench = common.createBenchmark(main, {
34
type: 'Array Buffer Int8Array Uint8Array Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array'.split(' '),

benchmark/arrays/zero-float.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
var common = require('../common.js');
23
var bench = common.createBenchmark(main, {
34
type: 'Array Buffer Int8Array Uint8Array Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array'.split(' '),

benchmark/arrays/zero-int.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
var common = require('../common.js');
23
var bench = common.createBenchmark(main, {
34
type: 'Array Buffer Int8Array Uint8Array Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array'.split(' '),

benchmark/buffers/buffer-base64-decode.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
var assert = require('assert');
23
var common = require('../common.js');
34

benchmark/buffers/buffer-base64-encode.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
var common = require('../common.js');
23

34
var bench = common.createBenchmark(main, {});

benchmark/buffers/buffer-bytelength.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
var common = require('../common');
23

34
var bench = common.createBenchmark(main, {

benchmark/buffers/buffer-compare.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
var common = require('../common.js');
23

34
var bench = common.createBenchmark(main, {

benchmark/buffers/buffer-creation.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
SlowBuffer = require('buffer').SlowBuffer;
1+
'use strict';
2+
const SlowBuffer = require('buffer').SlowBuffer;
23

34
var common = require('../common.js');
45
var bench = common.createBenchmark(main, {

benchmark/buffers/buffer-indexof.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
var common = require('../common.js');
23
var fs = require('fs');
34

benchmark/buffers/buffer-iterate.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
var SlowBuffer = require('buffer').SlowBuffer;
23
var common = require('../common.js');
34
var assert = require('assert');

benchmark/buffers/buffer-read.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
var common = require('../common.js');
23

34
var bench = common.createBenchmark(main, {

benchmark/buffers/buffer-slice.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
var common = require('../common.js');
23
var SlowBuffer = require('buffer').SlowBuffer;
34

benchmark/buffers/buffer-write.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
'use strict';
22
var common = require('../common.js');
33
var bench = common.createBenchmark(main, {
44
noAssert: [false, true],

benchmark/buffers/dataview-set.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
'use strict';
22
var common = require('../common.js');
33
var bench = common.createBenchmark(main, {
44
type: ['Uint8', 'Uint16LE', 'Uint16BE',

benchmark/common.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
var assert = require('assert');
23
var fs = require('fs');
34
var path = require('path');

benchmark/compare.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
var usage = 'node benchmark/compare.js ' +
23
'<node-binary1> <node-binary2> ' +
34
'[--html] [--red|-r] [--green|-g] ' +
@@ -38,9 +39,9 @@ for (var i = 2; i < process.argv.length; i++) {
3839

3940
if (!html) {
4041
var start = '';
41-
var green = '\033[1;32m';
42-
var red = '\033[1;31m';
43-
var reset = '\033[m';
42+
var green = '\u001b[1;32m';
43+
var red = '\u001b[1;31m';
44+
var reset = '\u001b[m';
4445
var end = '';
4546
} else {
4647
var start = '<pre style="background-color:#333;color:#eee">';

benchmark/crypto/aes-gcm-throughput.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
var common = require('../common.js');
23
var crypto = require('crypto');
34
var keylen = {'aes-128-gcm': 16, 'aes-192-gcm': 24, 'aes-256-gcm': 32};

benchmark/crypto/cipher-stream.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
var common = require('../common.js');
23

34
var bench = common.createBenchmark(main, {

benchmark/crypto/hash-stream-creation.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// throughput benchmark
22
// creates a single hasher, then pushes a bunch of data through it
3+
'use strict';
34
var common = require('../common.js');
45
var crypto = require('crypto');
56

benchmark/crypto/hash-stream-throughput.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// throughput benchmark
22
// creates a single hasher, then pushes a bunch of data through it
3+
'use strict';
34
var common = require('../common.js');
45
var crypto = require('crypto');
56

benchmark/crypto/rsa-encrypt-decrypt-throughput.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
// throughput benchmark in signing and verifying
23
var common = require('../common.js');
34
var crypto = require('crypto');

benchmark/crypto/rsa-sign-verify-throughput.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
// throughput benchmark in signing and verifying
23
var common = require('../common.js');
34
var crypto = require('crypto');

benchmark/events/ee-add-remove.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
var common = require('../common.js');
23
var events = require('events');
34

benchmark/events/ee-emit-multi-args.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
var common = require('../common.js');
23
var EventEmitter = require('events').EventEmitter;
34

benchmark/events/ee-emit.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
var common = require('../common.js');
23
var EventEmitter = require('events').EventEmitter;
34

benchmark/events/ee-listener-count-on-prototype.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
var common = require('../common.js');
23
var EventEmitter = require('events').EventEmitter;
34

benchmark/events/ee-listeners-many.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
var common = require('../common.js');
23
var EventEmitter = require('events').EventEmitter;
34

benchmark/events/ee-listeners.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
var common = require('../common.js');
23
var EventEmitter = require('events').EventEmitter;
34

benchmark/fs-write-stream-throughput.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
21
// If there are no args, then this is the root. Run all the benchmarks!
2+
'use strict';
33
if (!process.argv[2])
44
parent();
55
else

benchmark/fs/read-stream-throughput.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// test the throughput of the fs.WriteStream class.
2+
'use strict';
23

34
var path = require('path');
45
var common = require('../common.js');

benchmark/fs/readfile.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Call fs.readFile over and over again really fast.
22
// Then see how many times it got called.
33
// Yes, this is a silly benchmark. Most benchmarks are silly.
4+
'use strict';
45

56
var path = require('path');
67
var common = require('../common.js');

benchmark/fs/write-stream-throughput.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// test the throughput of the fs.WriteStream class.
2+
'use strict';
23

34
var path = require('path');
45
var common = require('../common.js');

benchmark/http/chunked.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// always as hot as it could be.
77
//
88
// Verify that our assumptions are valid.
9+
'use strict';
910

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

1920
function main(conf) {
20-
http = require('http');
21+
const http = require('http');
2122
var chunk = new Buffer(conf.size);
2223
chunk.fill('8');
2324

benchmark/http/client-request-body.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Measure the time it takes for the HTTP client to send a request body.
2+
'use strict';
23

34
var common = require('../common.js');
45
var http = require('http');

benchmark/http/cluster.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
var common = require('../common.js');
23
var PORT = common.PORT;
34

benchmark/http/end-vs-write-end.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// always as hot as it could be.
77
//
88
// Verify that our assumptions are valid.
9+
'use strict';
910

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

2021
function main(conf) {
21-
http = require('http');
22+
const http = require('http');
2223
var chunk;
2324
var len = conf.kb * 1024;
2425
switch (conf.type) {
@@ -27,7 +28,6 @@ function main(conf) {
2728
chunk.fill('x');
2829
break;
2930
case 'utf':
30-
encoding = 'utf8';
3131
chunk = new Array(len / 2 + 1).join('ü');
3232
break;
3333
case 'asc':

benchmark/http/simple.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
var common = require('../common.js');
23
var PORT = common.PORT;
34

benchmark/http_bench.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
var spawn = require('child_process').spawn;
23
var cluster = require('cluster');
34
var http = require('http');

benchmark/http_server_lag.js

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

benchmark/http_simple.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var path = require('path'),
24
exec = require('child_process').exec,
35
http = require('http');

benchmark/http_simple_auto.js

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// <args> Arguments to pass to `ab`.
77
// <target> Target to benchmark, e.g. `bytes/1024` or `buffer/8192`.
88
//
9+
'use strict';
910

1011
var path = require("path");
1112
var http = require("http");

benchmark/http_simple_cluster.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
var cluster = require('cluster');
23
var os = require('os');
34

benchmark/idle_clients.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
net = require('net');
1+
'use strict';
2+
const net = require('net');
23

34
var errors = 0, connections = 0;
45

benchmark/misc/child-process-read.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
var common = require('../common.js');
23
var bench = common.createBenchmark(main, {
34
len: [64, 256, 1024, 4096, 32768],

benchmark/misc/domain-fn-args.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
var common = require('../common.js');
23
var domain = require('domain');
34

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

1415
var args, ret, n = +conf.n;
15-
var arguments = gargs.slice(0, conf.arguments);
16+
var myArguments = gargs.slice(0, conf.arguments);
1617
bench.start();
1718

1819
bdomain.enter();
1920
for (var i = 0; i < n; i++) {
20-
if (arguments.length >= 2) {
21-
args = Array.prototype.slice.call(arguments, 1);
21+
if (myArguments.length >= 2) {
22+
args = Array.prototype.slice.call(myArguments, 1);
2223
ret = fn.apply(this, args);
2324
} else {
2425
ret = fn.call(this);

benchmark/misc/function_call/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// relative to a comparable C++ function.
33
// Reports millions of calls per second.
44
// Note that JS speed goes up, while cxx speed stays about the same.
5+
'use strict';
56

67
var assert = require('assert');
78
var common = require('../../common.js');

benchmark/misc/module-loader.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
var fs = require('fs');
23
var path = require('path');
34
var common = require('../common.js');

benchmark/misc/next-tick-breadth.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12

23
var common = require('../common.js');
34
var bench = common.createBenchmark(main, {

benchmark/misc/next-tick-depth.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
var common = require('../common.js');
23
var bench = common.createBenchmark(main, {
34
millions: [2]

benchmark/misc/spawn-echo.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
var common = require('../common.js');
23
var bench = common.createBenchmark(main, {
34
thousands: [1]

benchmark/misc/startup.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
var common = require('../common.js');
23
var spawn = require('child_process').spawn;
34
var path = require('path');

benchmark/misc/string-creation.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12

23
var common = require('../common.js');
34
var bench = common.createBenchmark(main, {

benchmark/misc/string-decoder.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
var common = require('../common.js');
23
var StringDecoder = require('string_decoder').StringDecoder;
34

benchmark/misc/timers.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
var common = require('../common.js');
23

34
var bench = common.createBenchmark(main, {

benchmark/misc/url.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
'use strict';
12
var url = require('url')
23
var n = 25 * 100;
34

benchmark/misc/v8-bench.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// compare with "google-chrome deps/v8/benchmarks/run.html"
2+
'use strict';
23
var fs = require('fs');
34
var path = require('path');
45
var vm = require('vm');

benchmark/net/net-c2s-cork.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// test the speed of .pipe() with sockets
2+
'use strict';
23

34
var common = require('../common.js');
45
var PORT = common.PORT;

benchmark/net/net-c2s.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// test the speed of .pipe() with sockets
2+
'use strict';
23

34
var common = require('../common.js');
45
var PORT = common.PORT;

benchmark/net/net-pipe.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// test the speed of .pipe() with sockets
2+
'use strict';
23

34
var common = require('../common.js');
45
var PORT = common.PORT;

benchmark/net/net-s2c.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// test the speed of .pipe() with sockets
2+
'use strict';
23

34
var common = require('../common.js');
45
var PORT = common.PORT;

benchmark/net/tcp-raw-c2s.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// In this benchmark, we connect a client to the server, and write
22
// as many bytes as we can in the specified time (default = 10s)
3+
'use strict';
34

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

0 commit comments

Comments
 (0)