Move cursor tracking out of the doc print buffer (#18202)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
bf95d3cdbe
commit
b87311a7cd
10 files changed
+325
-106
No files matched your search
@@ -0,0 +1,51 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { runBenchmark } from "./utilities.js";
|
||||
|
||||
for (const size of [1e1, 1e2, 1e3, 1e4, 1e5]) {
|
||||
const maxLength = 10;
|
||||
const seperator = "|";
|
||||
const strings = Array.from({ length: size }, () => "_");
|
||||
const expected = {
|
||||
length: strings.join(seperator).length,
|
||||
times: Math.floor(size / maxLength) - 1,
|
||||
};
|
||||
|
||||
await runBenchmark(
|
||||
{
|
||||
name: `String buffer compress (${size} strings)`,
|
||||
assert: (result) => assert.deepEqual(result, expected),
|
||||
},
|
||||
{
|
||||
"Array#splice()"() {
|
||||
const result = [];
|
||||
let times = 0;
|
||||
|
||||
for (let index = 0; index < strings.length; index++) {
|
||||
result.push(strings[index]);
|
||||
if (result.length > maxLength) {
|
||||
result.splice(0, Number.POSITIVE_INFINITY, result.join(seperator));
|
||||
assert.equal(result.length, 1);
|
||||
times++;
|
||||
}
|
||||
}
|
||||
|
||||
return { length: result.join(seperator).length, times };
|
||||
},
|
||||
"let reassign"() {
|
||||
let result = [];
|
||||
let times = 0;
|
||||
|
||||
for (let index = 0; index < strings.length; index++) {
|
||||
result.push(strings[index]);
|
||||
if (result.length > maxLength) {
|
||||
result = [result.join(seperator)];
|
||||
assert.equal(result.length, 1);
|
||||
times++;
|
||||
}
|
||||
}
|
||||
|
||||
return { length: result.join(seperator).length, times };
|
||||
},
|
||||
},
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user