-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Improve runner performance #466
Conversation
The Test constructor and buildPhases method are looking pretty ugly. Will need to be cleaned up later.
All working now, using benchmarks from jamestalmage/emoji-aware#no-assertion-plans: Master:
This PR:
|
Using the following benchmark (no assertions - just tracking runner performance): import test from './';
for (var i = 0; i < 10000; i++) {
test('test' + i, t => {});
} Master:
This PR:
|
This also seems to provide a slight performance boost for async tests: import test from './';
for (var i = 0; i < 10000; i++) {
test('test' + i, t => {return Promise.resolve()});
} Master:
This PR:
|
Mixed sync/async:
Master:
This PR:
|
|
||
function Concurrent(tests, bail) { | ||
if (!this instanceof Concurrent) { | ||
throw new Error('must use `new Concurrent`'); |
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.
Should be TypeError
to match ES2015 classes and message: Class constructor Concurrent cannot be invoked without 'new'
👏 From a quick skim this looks very promising, although a lot to take in. I like the improved separation of concerns and performance improvements, but not totally happy about the added verboseness. Would be nice if we could follow up later with ways to simplify it. I'll try to do a more thorough review tomorrow. @vdemedes @ariporad @sotojuan @novemberborn I could use some help reviewing this :) Tips for reviewing: Review the commits individually and use https://github.com/sindresorhus/ava/pull/466/files?w=1 to review the complete diff ignoring whitespace changes (for a more readable diff). |
Agreed. Getting a good benchmarking suite (#460) would be really helpful as well. |
Massive applause for huge amount of work, @jamestalmage. I have some style/cleanup-related suggestions, but I can follow up with a PR myself ;) |
Yes, let's do style stuff later. (I did a few myself, but realized it's better not to dilute the review with nitpicks). |
Once merged, we should all dogfood this on existing projects before release, (maybe deploy with a |
👍 I've already tried it on
👍 |
Currently in class but from what I skimmed it looks good :-) Awesome work! |
Landed! Awesome work @jamestalmage :) |
The main premise I had while creating this: Deferring when you don't need to is expensive.
This rewrites the runner and test to use the following semantics:
If a test never uses an async features (i.e.
cb
mode,t.throws(promise)
, return apromise
/observable
) the next test is executed synchronously.This requires a unified API between tests and the runner:
Because
run
can return either a result or a promise for a result, you frequently need to check which it is usingis-promise
. This leads to some verbose code, but it runs faster, and is fairly well encapsulated in thesequence
andconcurrent
classes.AVA master:
This PR: