Skip to content

Commit 194fc11

Browse files
RafaelGSStargos
authored andcommitted
benchmark: add buffer.isAscii benchmark
PR-URL: #54740 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 7410d51 commit 194fc11

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

benchmark/buffers/buffer-isascii.js

Lines 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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy