-
Notifications
You must be signed in to change notification settings - Fork 0
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
[DRAFT] - [perf] - wasm optimisations #6
base: develop
Are you sure you want to change the base?
Changes from 3 commits
3047a36
d87245f
10b3c7a
2274270
098bacf
32d3558
dab3d33
de6034d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.DS_Store | ||
node_modules | ||
vendor | ||
.idea | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
build | ||
build | ||
file-sizes.json | ||
Large diffs are not rendered by default.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lack of error handling: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea, you're right. Thanks for pointing that out. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import fs from "fs"; | ||
import path from "path"; | ||
|
||
const resultsFilePath = path.resolve("temp-all-test-results.json"); | ||
|
||
function readExistingResults() { | ||
if (fs.existsSync(resultsFilePath)) { | ||
const fileContent = fs.readFileSync(resultsFilePath, "utf-8"); | ||
return JSON.parse(fileContent); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The JSON.parse() call could throw an error if the file contents are malformed or not valid JSON. It's good to wrap this in a try-catch block to handle such cases. |
||
} | ||
return {}; | ||
} | ||
|
||
export function saveResults(newResults) { | ||
const existingResults = readExistingResults(); | ||
const combinedResults = { ...existingResults, ...newResults }; | ||
fs.writeFileSync(resultsFilePath, JSON.stringify(combinedResults, null, 2)); | ||
} | ||
|
||
export function addTestResults(testName, result) { | ||
if (process.env.GENERATE_REPORT === "true") { | ||
const tempResults = {}; | ||
tempResults[testName] = result; | ||
|
||
saveResults(tempResults); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we use this function anywhere else seems like it is only used in this one place. Maybe we don't need it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it's true, I will remove it and move the code to |
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add new line here ;)
POSIX ... If a file without a trailing newline is modified, Git's diff algorithm might show unexpected differences because the change will also affect the last line. Adding a newline at the end helps prevent diffs from being misleading.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, I did not know that. Thanks for mentioning it.