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: refactor benchmark/assert/throws.js · nodejs/node@9ada68b

File tree

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

‎benchmark/assert/throws.js‎

Copy file name to clipboardExpand all lines: benchmark/assert/throws.js
+7-9Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
const common = require('../common.js');
4-
const assert = require('assert');
4+
const { throws, doesNotThrow } = require('assert');
55

66
const bench = common.createBenchmark(main, {
77
n: [1e6],
@@ -14,8 +14,8 @@ const bench = common.createBenchmark(main, {
1414
});
1515

1616
function main({ n, method }) {
17-
const throws = () => { throw new TypeError('foobar'); };
18-
const doesNotThrow = () => { return 'foobar'; };
17+
const throwError = () => { throw new TypeError('foobar'); };
18+
const doNotThrowError = () => { return 'foobar'; };
1919
const regExp = /foobar/;
2020
const message = 'failure';
2121
var i;
@@ -26,30 +26,28 @@ function main({ n, method }) {
2626
case 'doesNotThrow':
2727
bench.start();
2828
for (i = 0; i < n; ++i) {
29-
// eslint-disable-next-line no-restricted-syntax
30-
assert.doesNotThrow(doesNotThrow);
29+
doesNotThrow(doNotThrowError);
3130
}
3231
bench.end(n);
3332
break;
3433
case 'throws':
3534
bench.start();
3635
for (i = 0; i < n; ++i) {
37-
// eslint-disable-next-line no-restricted-syntax
38-
assert.throws(throws);
36+
throws(throwError);
3937
}
4038
bench.end(n);
4139
break;
4240
case 'throws_TypeError':
4341
bench.start();
4442
for (i = 0; i < n; ++i) {
45-
assert.throws(throws, TypeError, message);
43+
throws(throwError, TypeError, message);
4644
}
4745
bench.end(n);
4846
break;
4947
case 'throws_RegExp':
5048
bench.start();
5149
for (i = 0; i < n; ++i) {
52-
assert.throws(throws, regExp, message);
50+
throws(throwError, regExp, message);
5351
}
5452
bench.end(n);
5553
break;

0 commit comments

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