-
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 1 commit
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 |
---|---|---|
@@ -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.
Lack of error handling:
If there is an error while reading or writing the file, it can cause the program to crash without any clear indication. You should wrap file operations in try-catch blocks to gracefully handle potential file system errors.
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.
Yea, you're right. Thanks for pointing that out.