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 rejects and doesNotReject bench · nodejs/node@2844180

File tree

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

‎benchmark/assert/rejects.js‎

Copy file name to clipboard
+27Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
method: ['rejects', 'doesNotReject'],
9+
});
10+
11+
async function main({ n, method }) {
12+
const fn = assert[method];
13+
const shouldReject = method === 'rejects';
14+
15+
bench.start();
16+
for (let i = 0; i < n; ++i) {
17+
await fn(async () => {
18+
const err = new Error(`assert.${method}`);
19+
if (shouldReject) {
20+
throw err;
21+
} else {
22+
return err;
23+
}
24+
});
25+
}
26+
bench.end(n);
27+
}

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.