Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 36.4k
performance,events: use Map to store events in EventEmitter#21856
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| 'use strict'; | ||
| const common = require('../common.js'); | ||
| const EventEmitter = require('events').EventEmitter; | ||
| const bench = common.createBenchmark(main, { | ||
| n: [2e7], | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems to be a pretty high iteration count. | ||
| listenerCount: [1, 5, 10], | ||
| }); | ||
| function main({ n, listenerCount }) { | ||
| const ee = new EventEmitter(); | ||
| for (var k = 0; k < listenerCount; k += 1) { | ||
| ee.on('dummy', function() {}); | ||
| ee.on(`dummy${k}`, function() {}); | ||
| } | ||
| bench.start(); | ||
| for (var i = 0; i < n; i += 1) { | ||
| if (i % 3 === 0) | ||
| ee.emit('dummy', true, 5); | ||
| else if (i % 2 === 0) | ||
| ee.emit('dummy', true, 5, 10, false); | ||
| else | ||
| ee.emit('dummy'); | ||
| } | ||
| bench.end(n); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| 'use strict'; | ||
| const common = require('../common.js'); | ||
| const EventEmitter = require('events').EventEmitter; | ||
| const bench = common.createBenchmark(main, { n: [1e6] }); | ||
| function main({ n }) { | ||
| const ee = new EventEmitter(); | ||
| for (var k = 0; k < 9; k += 1) { | ||
| ee.on(`dummy0${k}`, function() {}); | ||
| ee.on(`dummy1${k}`, function() {}); | ||
| ee.on(`dummy2${k}`, function() {}); | ||
| } | ||
| ee.removeAllListeners('dummy01'); | ||
| ee.removeAllListeners('dummy11'); | ||
| ee.removeAllListeners('dummy21'); | ||
| ee.removeAllListeners('dummy06'); | ||
| ee.removeAllListeners('dummy16'); | ||
| ee.removeAllListeners('dummy26'); | ||
| bench.start(); | ||
| for (var i = 0; i < n; i += 1) { | ||
| ee.eventNames(); | ||
| } | ||
| bench.end(n); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -2,7 +2,7 @@ | ||
| const common = require('../common.js'); | ||
| const EventEmitter = require('events').EventEmitter; | ||
| const bench = common.createBenchmark(main, { n: [5e6] }); | ||
| const bench = common.createBenchmark(main, { n: [1e7] }); | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we have to increase the iterations here? | ||
| function main({ n }) { | ||
| const ee = new EventEmitter(); | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really have to push up the iterations here?