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

This tests are not valid. #15

Open
maullerz opened this issue Dec 12, 2019 · 0 comments
Open

This tests are not valid. #15

maullerz opened this issue Dec 12, 2019 · 0 comments

Comments

@maullerz
Copy link

You are not taking in consideration time needed to work with memory, but you have to in such tests, where main work depends exactly on construction of big arrays and freeing them before next test.

Simple example.
In mapPerformance(posts) execution time of "forEach" depends on running order,
just move "forEach" block before "for loop", and you will see it starts to run "faster" than "for loop".

I have changed order and added 2 copies of tests, several runs:
posts.length: 100000

*************** Map performance check ***************
js map: 76.214ms
forEach1: 18.749ms
for loop1: 41.964ms
for loop2: 25.268ms
forEach2: 44.676ms
lodash map: 39.380ms
*************** Map performance check ***************
js map: 54.923ms
forEach1: 22.339ms
for loop1: 40.497ms
for loop2: 25.301ms
forEach2: 36.331ms
lodash map: 46.882ms
*************** Map performance check ***************
js map: 52.755ms
forEach1: 13.488ms
for loop1: 36.412ms
for loop2: 18.201ms
forEach2: 32.484ms
lodash map: 29.668ms
*************** Map performance check ***************
js map: 58.978ms
forEach1: 18.157ms
for loop1: 42.817ms
for loop2: 25.558ms
forEach2: 40.048ms
lodash map: 37.493ms

What we see? What conclusion?
What can we say with confidence?
Just that forEach and for loop have no difference and you can choose what you want.

PS:
node v10.16.1

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

No branches or pull requests

1 participant