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

mocha browser runner is 10-100x slower than jasmine on equivalent suites #763

Merged
merged 3 commits into from
Apr 3, 2013

Conversation

jfirebaugh
Copy link
Contributor

So @tmcw and I were petitioning to convert Leaflet's test suite to mocha and @mourner brought it to our attention that the result ran ten times slower (2s with mocha vs 0.2s with Jasmine).

I reproduced a similar slowdown in a simple benchmark which does nothing but execute 500 examples. Jasmine does it in about 0.1s, Mocha 3s.

I suspect Mocha is hitting a wall due to the latency of window.postMessage used by the process.nextTick implementation. Replacing this implementation with synchronous execution of fn leads to a sizable performance improvement (but of course regresses #153).

I guess to improve this mocha will need a nextTick worker queue and some manual scheduling logic, so that multiple ticks can run in each setTimeout/postMessage "timeslice".

@jfirebaugh
Copy link
Contributor Author

CC @shtylman in case he has ideas or is interested in implementing such a change in node-process's process.nextTick implementation.

@tj
Copy link
Contributor

tj commented Mar 5, 2013

yeah we could certainly combine a bunch of the ticks, it hasn't bothered me much yet personally since we have small test suites for all the components but this would be great to improve

@mourner
Copy link

mourner commented Mar 8, 2013

Yeah, I'd love to see this fixed, as there are a lot of cases where there's a big test case and performance is more important than small stack traces. Maybe make this configurable?

This roughly doubles browser performance. Still far
behind Jasmine however.

mochajs#763.
This roughly doubles performance again. Plus, the
scrolling is plain annoying.
This doubles performance again. Firefox should fix its damn
bug (mochajs#757).
@jfirebaugh
Copy link
Contributor Author

Converted this to a pull-request that gets mocha to ~2-3x slower than Jasmine via low-hanging fruit. The slow part now is the DOM manipulation in the HTML reporter.

tj added a commit that referenced this pull request Apr 3, 2013
mocha browser runner is 10-100x slower than jasmine on equivalent suites
@tj tj merged commit e22d85d into mochajs:master Apr 3, 2013
@jfirebaugh jfirebaugh deleted the browser_perf branch April 3, 2013 00:03
@tj
Copy link
Contributor

tj commented Apr 3, 2013

thanks man!

@mourner
Copy link

mourner commented Apr 4, 2013

@jfirebaugh John, you are the man! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants