We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c4d75ea commit fbe8351Copy full SHA for fbe8351
benchmark/util/text-encoder.js
@@ -0,0 +1,31 @@
1
+'use strict';
2
+
3
+const common = require('../common.js');
4
5
+const BASE = 'string\ud801';
6
7
+const bench = common.createBenchmark(main, {
8
+ n: [1e4],
9
+ op: ['encode', 'encodeInto']
10
+});
11
12
+function main({ n, ignoreBOM, op }) {
13
+ const encoder = new TextEncoder();
14
+ const input = BASE.repeat(n);
15
+ const subarray = new Uint8Array(n);
16
17
+ bench.start();
18
+ for (let i = 0; i < n; i++) {
19
+ switch (op) {
20
+ case 'encode': {
21
+ encoder.encode(input);
22
+ break;
23
+ }
24
+ case 'encodeInto': {
25
+ encoder.encodeInto(input, subarray);
26
27
28
29
30
+ bench.end(n);
31
+}
0 commit comments