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 buffer.isAscii benchmark · nodejs/node@af1988c

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • benchmark/buffers
    • buffer-isascii.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎benchmark/buffers/buffer-isascii.js‎

Copy file name to clipboard
+23Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict';
2+
3+
const common = require('../common.js');
4+
const buffer = require('node:buffer');
5+
const assert = require('node:assert');
6+
7+
const bench = common.createBenchmark(main, {
8+
n: [2e7],
9+
length: ['short', 'long'],
10+
input: ['hello world'],
11+
});
12+
13+
14+
function main({ n, input }) {
15+
const normalizedInput = input === 'short' ? input : input.repeat(200);
16+
const encoder = new TextEncoder();
17+
const buff = encoder.encode(normalizedInput);
18+
bench.start();
19+
for (let i = 0; i < n; ++i) {
20+
assert.ok(buffer.isAscii(buff));
21+
}
22+
bench.end(n);
23+
}

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.