Closed
Conversation
BridgeAR
approved these changes
Feb 28, 2019
BethGriggs
approved these changes
Feb 28, 2019
Member
|
Is |
Member
Author
|
When test count is small ( When test count is bigger ( Env: System:
OS: macOS 10.14.3
CPU: (8) x64 Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz
Memory: 1.27 GB / 16.00 GB
Shell: 3.0.0 - /usr/local/bin/fish
Binaries:
Node: 11.10.1 - /usr/local/bin/node
Yarn: 1.13.0 - /usr/local/bin/yarn
npm: 6.7.0 - /usr/local/bin/npmTest snippet const TEST_COUNT = Math.pow(10, 2);
const pojo = {
name: 'n',
age: 10
}
function Benckmark(desc, func) {
console.time(desc)
let sum = 0;
for (let index = 0; index < TEST_COUNT; index++) {
func()
}
console.timeEnd(desc)
}
const noop = () => {}
function forLoop(o) {
const keys = Object.keys(o)
for (let i = 0; i < keys.length; ++i) {
const key = keys[i]
noop(key)
}
}
function forOf(o) {
for (const key of Object.keys(o)) {
noop(key)
}
}
Benckmark('forLoop', () => forLoop(pojo))
Benckmark('forOf', () => forOf(pojo)) |
Member
|
@gengjiawen turning around the execution order is also going to turn around the results for what is faster for big The difference between the two loops is not very big but it is ~15%. See https://bugs.chromium.org/p/v8/issues/detail?id=8070 for the tracking bug that I opened last year for it. |
Member
BridgeAR
pushed a commit
to BridgeAR/node
that referenced
this pull request
Mar 5, 2019
PR-URL: nodejs#26354 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com>
Member
|
Landed in d79176a 🎉 |
BridgeAR
pushed a commit
to BridgeAR/node
that referenced
this pull request
Mar 12, 2019
PR-URL: nodejs#26354 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com>
BethGriggs
pushed a commit
that referenced
this pull request
Apr 16, 2019
PR-URL: #26354 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com>
Merged
This was referenced May 29, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes