GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — node/benchmark/assert/deepequal-prims-and-objs-big-array-set.js at main · styfle/node Expand file tree/ Copy pathdeepequal-prims-and-objs-big-array-set.jsMore file actions 71 lines (63 loc) · 1.69 KB / Copy pathdeepequal-prims-and-objs-big-array-set.jsFile metadata and controls71 lines (63 loc) · 1.69 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 'use strict'; const common = require('../common.js'); const { deepEqual, deepStrictEqual, notDeepEqual, notDeepStrictEqual } = require('assert'); const primValues = { 'string': 'a', 'number': 1, 'object': { 0: 'a' }, 'array': [1, 2, 3], }; const bench = common.createBenchmark(main, { primitive: Object.keys(primValues), n: [25], len: [2e4], strict: [0, 1], method: [ 'deepEqual_Array', 'notDeepEqual_Array', 'deepEqual_Set', 'notDeepEqual_Set', ], }); function run(fn, n, actual, expected) { bench.start(); for (let i = 0; i < n; ++i) { fn(actual, expected); } bench.end(n); } function main({ n, len, primitive, method, strict }) { const prim = primValues[primitive]; const actual = []; const expected = []; const expectedWrong = []; for (let x = 0; x < len; x++) { actual.push(prim); expected.push(prim); expectedWrong.push(prim); } expectedWrong.pop(); expectedWrong.push('b'); // Note: primitives are only added once to a set const actualSet = new Set(actual); const expectedSet = new Set(expected); const expectedWrongSet = new Set(expectedWrong); switch (method) { case 'deepEqual_Array': run(strict ? deepStrictEqual : deepEqual, n, actual, expected); break; case 'notDeepEqual_Array': run(strict ? notDeepStrictEqual : notDeepEqual, n, actual, expectedWrong); break; case 'deepEqual_Set': run(strict ? deepStrictEqual : deepEqual, n, actualSet, expectedSet); break; case 'notDeepEqual_Set': run(strict ? notDeepStrictEqual : notDeepEqual, n, actualSet, expectedWrongSet); break; default: throw new Error(`Unsupported method "${method}"`); } } |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |