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 test-performance use setImmediate instead of setTimeout #22093

Closed
wants to merge 1 commit into from

Conversation

fesebuv
Copy link

@fesebuv fesebuv commented Aug 2, 2018

The following pr reduces the time assertions take by replacing setTimeout by setImmediate that should make test run faster.

Also included some code refactor, make improve code readability.

Run

time ./node ./test/sequential/test-performance

Should see time reducing from real ~0m2.106s to real ~0m0.111s

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
@fesebuv fesebuv changed the title update test-performance use setInmmediate instead of setTimeout update test-performance use setImmediate instead of setTimeout Aug 2, 2018
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.

I'll leave it to the original authors to decide the validity of this change but this PR should be restricted to the described change.

E.g., the change to use forEach doesn't actually improve the code. And the style change of adding brackets around an if is also not meaningful.

};

function checkNodeTiming(props) {
Object.keys(props).forEach((prop) => {
Copy link
Member

Choose a reason for hiding this comment

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

Why this change? This isn't faster or better.

Copy link
Author

Choose a reason for hiding this comment

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

No is not, but if you are invoking a chain-able method for an array, might as well chain and iterate no?

@@ -4,8 +4,9 @@ const common = require('../common');
const assert = require('assert');
const { performance } = require('perf_hooks');

if (!common.isMainThread)
if (!common.isMainThread) {
Copy link
Member

Choose a reason for hiding this comment

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

Unrelated change.

Copy link
Author

Choose a reason for hiding this comment

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

I'm just trying to improve the code a little bit sir.

startTime: 0,
checkNodeTiming(timingParams);

setImmediate(() => {
Copy link
Member

Choose a reason for hiding this comment

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

I would assume there's a reason the original test case used both setImmediate and setTimeout.

…Timeout & refactor

do not need to redifine duration
@fesebuv fesebuv force-pushed the fesebuv-update-test branch from ad115db to fa3f2a0 Compare August 2, 2018 19:10
@Trott
Copy link
Member

Trott commented Aug 3, 2018

I'll leave it to the original authors to decide the validity of this change

The setTimeout() was added in 9256dbb by @TimothyGu.

@fesebuv
Copy link
Author

fesebuv commented Aug 6, 2018

Based on the following comment #20128 (comment) I will follow up by closing this pr.

Thanks for the review @Trott @apapirovski

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