diff options
author | Anatoli Papirovski <apapirovski@mac.com> | 2018-05-01 13:32:10 +0200 |
---|---|---|
committer | Anatoli Papirovski <apapirovski@mac.com> | 2018-05-03 14:45:09 +0200 |
commit | fe8794560a22cc62a482bf071e2050ce1ea6ea3e (patch) | |
tree | 385772d3828d99e14d805c1aa3196ccebc4e1c78 /benchmark | |
parent | 2553377d118f8762bbb665936e4ce41eb84bf3bb (diff) | |
download | node-new-fe8794560a22cc62a482bf071e2050ce1ea6ea3e.tar.gz |
events: optimize condition for optimal scenario
Instead of always checking whether we've already warned about a
possible EventEmitter memory leak, first run the rest of the
code as accessing random properties on an Array is expensive.
In addition, remove an unnecessary truthy check.
PR-URL: https://github.com/nodejs/node/pull/20452
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Diffstat (limited to 'benchmark')
-rw-r--r-- | benchmark/events/ee-add-remove.js | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/benchmark/events/ee-add-remove.js b/benchmark/events/ee-add-remove.js index eee8ff4524..54e680f74a 100644 --- a/benchmark/events/ee-add-remove.js +++ b/benchmark/events/ee-add-remove.js @@ -2,7 +2,7 @@ const common = require('../common.js'); const events = require('events'); -const bench = common.createBenchmark(main, { n: [25e4] }); +const bench = common.createBenchmark(main, { n: [1e6] }); function main({ n }) { const ee = new events.EventEmitter(); |