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

Update benchmark.js test file in order to reduce the time test-benchmark-buffer test takes to run #22090

Closed
wants to merge 1 commit into from

Conversation

fesebuv
Copy link

@fesebuv fesebuv commented Aug 2, 2018

The following pr updates the runBenchMark function by:

  1. Breaking the runBenchMark function into the getArgv for the purpose of getting the argv array.
  2. When constructing the argv array, we are reducing the args array parameter. That way we make one push operation instead of two per iteration.
  3. Instead of contatinating an array per iteration on line https://github.com/nodejs/node/compare/master...fesebuv:fesebuv-updates?expand=1#diff-f282ba153a1c9657bd17a47caabab8bfR29 we are pushing that line into an array and then joining that array when needed.

Run

time ./node ./test/sequential/test-benchmark-buffer

  • Should see time reducing from real ~0m5.570s to real ~0m5.479s
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label Aug 2, 2018
@mscdex
Copy link
Contributor

mscdex commented Aug 2, 2018

That kind of difference in results seems like it would be within the margin of error and not necessarily a consistent, measurable improvement? In general though, the last time I checked string concatenation would be faster than array pushing and joining.

@fesebuv
Copy link
Author

fesebuv commented Aug 2, 2018

🤔 perhaps. But as it was pointed out, the difference is "within the margin of error". What I am attempting to do is a little bit of code refactoring, improve readability, etc.

Copy link
Member

@apapirovski apapirovski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That difference is almost certainly within margin of error. If we want to improve performance there certainly better ways than creating an extra closure and replacing a fast for loop with a reduce that constantly reallocates arrays.

@fesebuv
Copy link
Author

fesebuv commented Aug 2, 2018

@apapirovski understood!

@fesebuv
Copy link
Author

fesebuv commented Aug 6, 2018

Based on the following comment:
#20128 (comment)

And since the updates made on this pr are not significant. I am closing this pr.
Thanks for reviewing @apapirovski @mscdex

I look forward to contribute elsewhere.

@fesebuv fesebuv closed this Aug 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants