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
Add benchmarks #101
Add benchmarks #101
Conversation
benchmark.js
Outdated
// https://github.com/bestiejs/benchmark.js/issues/136 | ||
createFixtures(); | ||
|
||
// Async await was giving too many errors. stick with standard promises |
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.
Huh? What does this mean? Async/await shouldn't work any differently.
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.
suite.add({
name,
defer: true,
// if you remove setup() the benchmark works as expected
setup() {
},
async fn(deferred) {
// Can't use setup because it isn't called after every defer
// https://github.com/bestiejs/benchmark.js/issues/136
createFixtures();
// Async await was giving too many errors. stick with standard promises
await del(['**/*'], {
cwd: tempDir,
concurrency,
// eslint-disable-next-line promise/prefer-await-to-then
}).then(removedFiles => {
if (removedFiles.length !== fixtures.length) {
const error = new Error(
`"${name}": files removed: ${removedFiles.length}, expected: ${fixtures.length}`,
);
console.error(error);
del.sync(tempDir, { cwd: tempDir, force: true });
// eslint-disable-next-line unicorn/no-process-exit
process.exit(1);
}
deferred.resolve();
});
},
});
Gives the error:
del on add-benchmarks [⇡!] is 📦 v5.0.0 via ⬢ v10.16.0 took 6s
➜ node benchmark.js
undefined:9
await del(['**/*'], {
^^^^^
SyntaxError: await is only valid in async function
at Function (<anonymous>)
at createCompiled (/Users/chris/github/del/node_modules/benchmark/benchmark.js:1725:16)
at clock (/Users/chris/github/del/node_modules/benchmark/benchmark.js:1608:58)
at clock (/Users/chris/github/del/node_modules/benchmark/benchmark.js:1818:20)
at new Deferred (/Users/chris/github/del/node_modules/benchmark/benchmark.js:405:7)
at Deferred (/Users/chris/github/del/node_modules/benchmark/benchmark.js:402:16)
at Benchmark.run (/Users/chris/github/del/node_modules/benchmark/benchmark.js:2112:13)
at execute (/Users/chris/github/del/node_modules/benchmark/benchmark.js:860:74)
at Timeout._onTimeout (/Users/chris/github/del/node_modules/lodash/lodash.js:2750:43)
at ontimeout (timers.js:436:11)
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.
Weird. I already commented on this, but it's gone now... Anyway, I think you're just missing the async
keyword for the method. Then it worked for me at least.
Results for me on Node.js 12.6.0 and macOS 10.14:
How about you? |
On my desktop:
On my laptop:
|
Also, if you have any ideas how to remove |
Seems like 100 would be a good default. Maybe you could add 200, 300, 400, 500, 1000 to the benchmark too? Just to check. |
Added! From my laptop:
|
I've resolved the merge conflict and updated to async await. I added the line that demonstrates why I was using normal promises. Let me know if you want me to revert the async await change or remove the |
Are you able to run Line 45 in 12c443d
Is causing the following error for me: ➜ node benchmark.js
undefined:9
const removedFiles = await del(['**/*'], {
^^^^^
SyntaxError: await is only valid in async function
at Function (<anonymous>)
at createCompiled (/Users/chris/github/del/node_modules/benchmark/benchmark.js:1725:16) |
I just forgot to remove the setup method before merging as I had intended to: 728cb7c |
This is not necessarily meant to be merged as is, but meant to try and answer #60.