{"action":"created","issue":{"url":"https://api.github.com/repos/nodejs/help/issues/373","repository_url":"https://api.github.com/repos/nodejs/help","labels_url":"https://api.github.com/repos/nodejs/help/issues/373/labels{/name}","comments_url":"https://api.github.com/repos/nodejs/help/issues/373/comments","events_url":"https://api.github.com/repos/nodejs/help/issues/373/events","html_url":"https://github.com/nodejs/help/issues/373","id":190779711,"number":373,"title":"Some strange deoptimization?","user":{"login":"vsemozhetbyt","id":10393198,"avatar_url":"https://avatars.githubusercontent.com/u/10393198?v=3","gravatar_id":"","url":"https://api.github.com/users/vsemozhetbyt","html_url":"https://github.com/vsemozhetbyt","followers_url":"https://api.github.com/users/vsemozhetbyt/followers","following_url":"https://api.github.com/users/vsemozhetbyt/following{/other_user}","gists_url":"https://api.github.com/users/vsemozhetbyt/gists{/gist_id}","starred_url":"https://api.github.com/users/vsemozhetbyt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vsemozhetbyt/subscriptions","organizations_url":"https://api.github.com/users/vsemozhetbyt/orgs","repos_url":"https://api.github.com/users/vsemozhetbyt/repos","events_url":"https://api.github.com/users/vsemozhetbyt/events{/privacy}","received_events_url":"https://api.github.com/users/vsemozhetbyt/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-11-21T17:08:57Z","updated_at":"2016-11-21T23:48:46Z","closed_at":null,"body":"Node.js 7.1.0 on Windows 7 x64.\r\n\r\nI am trying to write a simple benchmark function. It has two arguments: an array of functions to run for comparison and a number of call repetition for these functions. Here is the code:\r\n```js\r\nfunction bm(funcs, numberOfCycles = 100) {\r\n  const NS_IN_S = 1e9;\r\n\r\n  Object.keys(funcs).forEach(name => {\r\n    process.stdout.write(`${name}: `);\r\n\r\n    const hrStart = process.hrtime();\r\n\r\n    for (let i = 0; i < numberOfCycles; i++) funcs[name]();\r\n\r\n    const [s, ns] = process.hrtime(hrStart);\r\n    const diff = (s * NS_IN_S + ns) / NS_IN_S;\r\n\r\n    process.stdout.write(`${diff.toLocaleString()} s\\n`);\r\n  });\r\n}\r\n```\r\nHowever, the time of the first cycles batch is allways three time faster than other batches, even for the identical code or the empty code:\r\n```js\r\nbm({\r\n  f1() {},\r\n  f2() {},\r\n  f3() {},\r\n  f4() {},\r\n}, 100000000);\r\n```\r\n```\r\nf1: 1.184 s\r\nf2: 2.938 s\r\nf3: 2.932 s\r\nf4: 2.929 s\r\n```\r\nWhat am I doing wrong?"},"comment":{"url":"https://api.github.com/repos/nodejs/help/issues/comments/262104498","html_url":"https://github.com/nodejs/help/issues/373#issuecomment-262104498","issue_url":"https://api.github.com/repos/nodejs/help/issues/373","id":262104498,"user":{"login":"vsemozhetbyt","id":10393198,"avatar_url":"https://avatars.githubusercontent.com/u/10393198?v=3","gravatar_id":"","url":"https://api.github.com/users/vsemozhetbyt","html_url":"https://github.com/vsemozhetbyt","followers_url":"https://api.github.com/users/vsemozhetbyt/followers","following_url":"https://api.github.com/users/vsemozhetbyt/following{/other_user}","gists_url":"https://api.github.com/users/vsemozhetbyt/gists{/gist_id}","starred_url":"https://api.github.com/users/vsemozhetbyt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vsemozhetbyt/subscriptions","organizations_url":"https://api.github.com/users/vsemozhetbyt/orgs","repos_url":"https://api.github.com/users/vsemozhetbyt/repos","events_url":"https://api.github.com/users/vsemozhetbyt/events{/privacy}","received_events_url":"https://api.github.com/users/vsemozhetbyt/received_events","type":"User","site_admin":false},"created_at":"2016-11-21T23:48:46Z","updated_at":"2016-11-21T23:48:46Z","body":"Closed in favor of [this more basic issue](https://github.com/nodejs/node/issues/9729)."}}
{"actor":{"display_login":"vsemozhetbyt"}}