| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff 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: ['regular string', '∀x∈ℝ: ⌈x⌉ = −⌊−x⌋'], | ||
| 11 | + }); | ||
| 12 | + | ||
| 13 | + | ||
| 14 | + function main({ n, input, length }) { | ||
| 15 | + const normalizedInput = length === 'short' ? input : input.repeat(300); | ||
| 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.isUtf8(buff)); | ||
| 21 | + } | ||
| 22 | + bench.end(n); | ||
| 23 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments