Skip to content

Commit

Permalink
benchmark: add util.toUSVString()'s benchmark
Browse files Browse the repository at this point in the history
PR-URL: #40203
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
  • Loading branch information
XadillaX authored and targos committed Oct 4, 2021
1 parent 685c7d4 commit 34f3021
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions benchmark/util/to-usv-string.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';

const common = require('../common');

const BASE = 'string\ud801';

const bench = common.createBenchmark(main, {
n: [1e5],
size: [10, 100, 500],
});

function main({ n, size }) {
const { toUSVString } = require('util');
const str = BASE.repeat(size);

bench.start();
for (let i = 0; i < n; i++) {
toUSVString(str);
}
bench.end(n);
}

0 comments on commit 34f3021

Please sign in to comment.