-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
events: remove emit micro-optimizations
With improvements in V8, using separate emit functions is no longer necessary and can instead be replaced by the spread operator. improvement confidence p.value events/ee-emit.js n=2000000 2.98 % 0.09852489 events/ee-emit-2-args.js n=2000000 4.19 % *** 0.0001914216 events/ee-emit-6-args.js n=2000000 61.69 % *** 6.611964e-35 events/ee-emit-diff-args.js n=2000000 -0.36 % 0.305069 events/ee-once.js n=20000000 6.42 % *** 1.27831e-06
- Loading branch information
1 parent
70dc6d5
commit b659275
Showing
4 changed files
with
33 additions
and
91 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
'use strict'; | ||
const common = require('../common.js'); | ||
const EventEmitter = require('events').EventEmitter; | ||
|
||
const bench = common.createBenchmark(main, { n: [2e6] }); | ||
|
||
function main(conf) { | ||
const n = conf.n | 0; | ||
|
||
const ee = new EventEmitter(); | ||
|
||
for (var k = 0; k < 10; k += 1) | ||
ee.on('dummy', function() {}); | ||
|
||
bench.start(); | ||
for (var i = 0; i < n; i += 1) { | ||
ee.emit('dummy', 5, true, 'something', false); | ||
} | ||
bench.end(n); | ||
} |
This file contains 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
This file contains 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