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-map.js at main · GLStephen/node Expand file tree/ Copy pathdeepequal-map.jsMore file actions 80 lines (75 loc) · 2.38 KB / Copy pathdeepequal-map.jsFile metadata and controls80 lines (75 loc) · 2.38 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 72 73 74 75 76 77 78 79 80 'use strict'; const common = require('../common.js'); const { deepEqual, deepStrictEqual, notDeepEqual, notDeepStrictEqual } = require('assert'); const bench = common.createBenchmark(main, { n: [5e2], len: [5e2], strict: [0, 1], method: [ 'deepEqual_primitiveOnly', 'deepEqual_objectOnly', 'deepEqual_mixed', 'notDeepEqual_primitiveOnly', 'notDeepEqual_objectOnly', 'notDeepEqual_mixed', ], }); function benchmark(method, n, values, values2) { const actual = new Map(values); // Prevent reference equal elements const deepCopy = JSON.parse(JSON.stringify(values2 ? values2 : values)); const expected = new Map(deepCopy); bench.start(); for (let i = 0; i < n; ++i) { method(actual, expected); } bench.end(n); } function main({ n, len, method, strict }) { const array = Array(len).fill(1); switch (method) { case 'deepEqual_primitiveOnly': { const values = array.map((_, i) => [`str_${i}`, 123]); benchmark(strict ? deepStrictEqual : deepEqual, n, values); break; } case 'deepEqual_objectOnly': { const values = array.map((_, i) => [[`str_${i}`, 1], 123]); benchmark(strict ? deepStrictEqual : deepEqual, n, values); break; } case 'deepEqual_mixed': { const values = array.map( (_, i) => [i % 2 ? [`str_${i}`, 1] : `str_${i}`, 123] ); benchmark(strict ? deepStrictEqual : deepEqual, n, values); break; } case 'notDeepEqual_primitiveOnly': { const values = array.map((_, i) => [`str_${i}`, 123]); const values2 = values.slice(0); values2[Math.floor(len / 2)] = ['w00t', 123]; benchmark(strict ? notDeepStrictEqual : notDeepEqual, n, values, values2); break; } case 'notDeepEqual_objectOnly': { const values = array.map((_, i) => [[`str_${i}`, 1], 123]); const values2 = values.slice(0); values2[Math.floor(len / 2)] = [['w00t'], 123]; benchmark(strict ? notDeepStrictEqual : notDeepEqual, n, values, values2); break; } case 'notDeepEqual_mixed': { const values = array.map( (_, i) => [i % 2 ? [`str_${i}`, 1] : `str_${i}`, 123] ); const values2 = values.slice(0); values2[0] = ['w00t', 123]; benchmark(strict ? notDeepStrictEqual : notDeepEqual, n, values, values2); 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. |