GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — benchmark: add strictEqual and notStrictEqual bench · nodejs/node@8f10156

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • benchmark/assert
    • strictequal.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎benchmark/assert/strictequal.js‎

Copy file name to clipboard
+43Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
'use strict';
2+
3+
const common = require('../common.js');
4+
const assert = require('assert');
5+
6+
const bench = common.createBenchmark(main, {
7+
n: [25, 2e5],
8+
type: ['string', 'object', 'number'],
9+
method: ['strictEqual', 'notStrictEqual'],
10+
});
11+
12+
function main({ type, n, method }) {
13+
const fn = assert[method];
14+
let actual, expected;
15+
switch (type) {
16+
case 'string':
17+
actual = expected = 'Hello World';
18+
if (method === 'notStrictEqual') {
19+
expected += 'bar';
20+
}
21+
break;
22+
case 'object':
23+
actual = expected = { a: 'Hello', b: 'World' };
24+
if (method === 'notStrictEqual') {
25+
expected = { a: 'Hello', b: 'World' };
26+
}
27+
break;
28+
case 'number':
29+
actual = expected = 1e9;
30+
if (method === 'notStrictEqual') {
31+
expected += 1;
32+
}
33+
break;
34+
default:
35+
throw new Error('Unexpected type');
36+
}
37+
38+
bench.start();
39+
for (let i = 0; i < n; ++i) {
40+
fn(actual, expected);
41+
}
42+
bench.end(n);
43+
}

0 commit comments

Comments
0 (0)
You are visitor 01402503 — 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.