mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
2f8d81ece3
PR-URL: https://github.com/nodejs/node/pull/54740 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
24 lines
548 B
JavaScript
24 lines
548 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common.js');
|
|
const buffer = require('node:buffer');
|
|
const assert = require('node:assert');
|
|
|
|
const bench = common.createBenchmark(main, {
|
|
n: [2e7],
|
|
length: ['short', 'long'],
|
|
input: ['hello world'],
|
|
});
|
|
|
|
|
|
function main({ n, input }) {
|
|
const normalizedInput = input === 'short' ? input : input.repeat(200);
|
|
const encoder = new TextEncoder();
|
|
const buff = encoder.encode(normalizedInput);
|
|
bench.start();
|
|
for (let i = 0; i < n; ++i) {
|
|
assert.ok(buffer.isAscii(buff));
|
|
}
|
|
bench.end(n);
|
|
}
|