From a7189c0177938545050421a600fb12c21db3858f Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Wed, 28 Jun 2017 20:34:19 +0200 Subject: benchmark: fix and extend assert benchmarks The benchmarks had the strict and non strict labels switched. This is fixed and the benchmarks were extended to check more possible input types and function calls. PR-URL: https://github.com/nodejs/node/pull/14147 Refs: https://github.com/nodejs/node/pull/13973 Reviewed-By: Refael Ackermann Reviewed-By: James M Snell --- benchmark/assert/deepequal-buffer.js | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) (limited to 'benchmark/assert/deepequal-buffer.js') diff --git a/benchmark/assert/deepequal-buffer.js b/benchmark/assert/deepequal-buffer.js index 2a7d9e3bed..9e86aa231e 100644 --- a/benchmark/assert/deepequal-buffer.js +++ b/benchmark/assert/deepequal-buffer.js @@ -1,10 +1,16 @@ 'use strict'; const common = require('../common.js'); const assert = require('assert'); + const bench = common.createBenchmark(main, { - n: [1e3], - len: [1e2], - method: ['strict', 'nonstrict'] + n: [1e5], + len: [1e2, 1e4], + method: [ + 'deepEqual', + 'deepStrictEqual', + 'notDeepEqual', + 'notDeepStrictEqual' + ] }); function main(conf) { @@ -12,14 +18,16 @@ function main(conf) { const len = +conf.len; var i; - const data = Buffer.allocUnsafe(len); + const data = Buffer.allocUnsafe(len + 1); const actual = Buffer.alloc(len); const expected = Buffer.alloc(len); + const expectedWrong = Buffer.alloc(len + 1); data.copy(actual); data.copy(expected); + data.copy(expectedWrong); switch (conf.method) { - case 'strict': + case 'deepEqual': bench.start(); for (i = 0; i < n; ++i) { // eslint-disable-next-line no-restricted-properties @@ -27,13 +35,28 @@ function main(conf) { } bench.end(n); break; - case 'nonstrict': + case 'deepStrictEqual': bench.start(); for (i = 0; i < n; ++i) { assert.deepStrictEqual(actual, expected); } bench.end(n); break; + case 'notDeepEqual': + bench.start(); + for (i = 0; i < n; ++i) { + // eslint-disable-next-line no-restricted-properties + assert.notDeepEqual(actual, expectedWrong); + } + bench.end(n); + break; + case 'notDeepStrictEqual': + bench.start(); + for (i = 0; i < n; ++i) { + assert.notDeepStrictEqual(actual, expectedWrong); + } + bench.end(n); + break; default: throw new Error('Unsupported method'); } -- cgit v1.2.3