Skip to content

Give the ember tests some idiomatic love.. #7

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

Closed
wants to merge 1 commit into from

Conversation

stefanpenner
Copy link

  • Utilize ember's run-loop as it was meant to be utilized.
  • Use minified ember build, as this is closer to production.

Please note, this is a quite unnatural test. Forcing typically temporally distinct operations (such as user clicks) to be synchronous, grinds against some frameworks architecture. I do not believe these tests are trying explicitly to mis-represent, but
I fear this approach is flawed. This commit allows ember's run-loop to do what it was
Intended todo, which helps dramatically.

I would love to find a more natural method of testing these types of scenarios.

- Utilize ember's run-loop as it was meant to be utilized.
- Use minified ember build, as this is closer to production.

Please  note, this is a quite unnatural test. Forcing typically temporally distinct operations (such as user clicks) to be synchronous, grinds against some frameworks architecture. I do not believe these tests are trying explicitly to mis-represent, but
I fear this approach is flawed. This commit allows ember's run-loop to do what it was
Intended todo, which helps dramatically.

I would love to find a more natural method of testing these types of scenarios.
@stefanpenner
Copy link
Author

one example run:

EmberJS-TodoMVC : Adding100Items : Sync: 263.98099993821234 ms
EmberJS-TodoMVC : Adding100Items : Async: 37.08800009917468 ms
EmberJS-TodoMVC : CompletingAllItems : Sync: 86.75300003960729 ms
EmberJS-TodoMVC : CompletingAllItems : Async: 16.9139999197796 ms
EmberJS-TodoMVC : DeletingItems : Sync: 251.93100003525615 ms
EmberJS-TodoMVC : DeletingItems : Async: 14.462999999523163 ms
EmberJS-TodoMVC : 671.1300000315532 ms

seems to be between 500ms -> 750ms depending on what appears to be common jitter.

@yyx990803
Copy link
Member

Hey Stefan, thanks a lot for the suggestion. This is really impressive perf gain, but here's my thoughts:

To my understanding, the benchmark intends to simulate user actions. Admitted, firing all the events in a synchronous for loop is unlikely to happen for a real user. But in my opinion, the point of the for loop is not stressing the runtime but rather increasing the sample size to counter fluctuation (potentially caused by GC) and browser timing accuracy issues. Logically, each iteration should be considered a separate event. What we actually want to measure is the time needed for the framework to fully propagate the changes and manipulate the DOM for just one iteration. In that sense, the for loop is a test fixture and all framework specific code should happen inside, and that is the case for every other framework in the test. Allowing Ember to wrap the entire loop in its own run loop seems to be giving it unfair advantage.

@stefanpenner
Copy link
Author

I believe we should strive for an accurate and healthy benchmark or strategy of benchmarks. I would love to brain storm with you if you have time.

Ideas:

  • tests resembling real life scenarios.
  • tests that can be genuinely used to improve those real scenarios.

I wonder if using microtime, and running interactions at the healthy multiple of the rate users would natural interact with an application would yield much more valuable results. This should result in realistic GC pressure, and DOM pressure.

Additionally, the N we should increase, is the cost PER user interaction, rather then increasing the number of interactions. An example would be.

A User triggering an action causing:

  • N things to be added to a list, were we grow N, -> 0...1000
  • N things to mutate, were we grow N, -> 0...1000
  • N things to to be removed,

We would then run with a series of distinct and separate tests were we grow N from x -> y [1...1000] Allowing for healthy pauses, which should mimic user interactions, puttying realistic stresses on the run-time.

Another aspect is, data entering the app via another strategy, such as websocket, or xhr. For this we likely need N + Y, N is the amount of change, and Y is the frequency.

I believe this theme is more aligned with reality. Likely can be thought of as the difference between using AB to test a webserver, and an httperf script that mimics reality.

@stefanpenner
Copy link
Author

Also, if you are interested. Forcing a full flush after each event resulted in some slow down, but not nearly as much as the original

Averaging around:

EmberJS-TodoMVC : Adding100Items : Sync: 310.23699999786913 ms
EmberJS-TodoMVC : Adding100Items : Async: 41.82399995625019 ms
EmberJS-TodoMVC : CompletingAllItems : Sync: 131.84699998237193 ms
EmberJS-TodoMVC : CompletingAllItems : Async: 49.811999895609915 ms
EmberJS-TodoMVC : DeletingItems : Sync: 341.8860000092536 ms
EmberJS-TodoMVC : DeletingItems : Async: 18.564999918453395 ms
EmberJS-TodoMVC : 894.1709997598082 ms
Run 7/1 - Total : 894.1709997598082 ms

Ranging from 800ms -> 1100ms

@stefanpenner
Copy link
Author

Another perspective would be, what if we tested file-system writes with 0 buffers, forcing sync to disk for each byte written. This would be entirely un-realistic and if made faster, would only result in degraded performance for end-users.

@duckbox
Copy link

duckbox commented Feb 13, 2014

For measuring each iteration, perhaps something like https://github.com/btford/zone.js/ may come in handy?

@stefanpenner
Copy link
Author

@duckbox interesting, ya it may.

@yyx990803
Copy link
Member

Closing this because the original PR no longer applies. Still open for discussion regarding a more natural benchmark - although that's probably out of scope for this repo.

@yyx990803 yyx990803 closed this Mar 5, 2014
dingyiming pushed a commit that referenced this pull request Dec 21, 2016
dingyiming pushed a commit that referenced this pull request Dec 21, 2016
logaretm pushed a commit to logaretm/vuejs.org that referenced this pull request Jun 7, 2020
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.

3 participants