Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: concat performance #422

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add failing test
  • Loading branch information
styfle committed Jun 3, 2024
commit 5be45fd8c4a5c8aa67c16db3a9232eaf838b0b99
4 changes: 4 additions & 0 deletions test/unit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ for (const { testName, isRoot } of unitTests) {
inputFileNames.push('input-2.js', 'input-3.js', 'input-4.js');
}

const startTime = Date.now();
const { fileList, reasons } = await nodeFileTrace(
inputFileNames.map((file) => join(unitPath, file)),
{
Expand All @@ -155,6 +156,9 @@ for (const { testName, isRoot } of unitTests) {
},
);

const totalTime = Date.now() - startTime;
expect(totalTime).toBeLessThan(1000);

const normalizeFilesRoot = (f) =>
(isRoot ? relative(join('./', __dirname, '..'), f) : f).replace(
/\\/g,
Expand Down
24 changes: 24 additions & 0 deletions test/unit/string-concat-chain/input.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
var str = './lib/'
.concat('1')
.concat('_', '2')
.concat('_', '3')
.concat('_', '4')
.concat('_', '5')
.concat('_', '6')
.concat('_', '7')
.concat('_', '8')
.concat('_', '9')
.concat('_', '10')
.concat('_', '11')
.concat('_', '12')
.concat('_', '13')
.concat('_', '14')
.concat('_', '15')
.concat('_', '16')
.concat('_', '17')
.concat('_', '18')
.concat('_', '19')
.concat('_', '20')
.concat('.js');

require(str);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = { file: 'file' }
5 changes: 5 additions & 0 deletions test/unit/string-concat-chain/output.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[
"package.json",
"test/unit/string-concat-chain/input.js",
"test/unit/string-concat-chain/lib/1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16_17_18_19_20.js"
]
Loading