-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
benchmark: add more EventEmitter benchmarks
PR-URL: #730 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Brendan Ashworth <[email protected]>
- Loading branch information
1 parent
96597bc
commit 847b9d2
Showing
5 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
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 @@ | ||
var common = require('../common.js'); | ||
var EventEmitter = require('events').EventEmitter; | ||
|
||
var bench = common.createBenchmark(main, {n: [25e4]}); | ||
|
||
function main(conf) { | ||
var n = conf.n | 0; | ||
|
||
var ee = new EventEmitter(); | ||
var listeners = []; | ||
|
||
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); | ||
} | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
var common = require('../common.js'); | ||
var EventEmitter = require('events').EventEmitter; | ||
|
||
var bench = common.createBenchmark(main, {n: [25e4]}); | ||
|
||
function main(conf) { | ||
var n = conf.n | 0; | ||
|
||
var 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'); | ||
} | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
var common = require('../common.js'); | ||
var EventEmitter = require('events').EventEmitter; | ||
|
||
var bench = common.createBenchmark(main, {n: [25e4]}); | ||
|
||
function main(conf) { | ||
var n = conf.n | 0; | ||
|
||
var ee = new EventEmitter(); | ||
var listenerCount = EventEmitter.listenerCount; | ||
|
||
for (var k = 0; k < 10; k += 1) | ||
ee.on('dummy', function() {}); | ||
|
||
bench.start(); | ||
for (var i = 0; i < n; i += 1) { | ||
var r = listenerCount(ee, 'dummy'); | ||
} | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
var common = require('../common.js'); | ||
var EventEmitter = require('events').EventEmitter; | ||
|
||
var bench = common.createBenchmark(main, {n: [25e4]}); | ||
|
||
function main(conf) { | ||
var n = conf.n | 0; | ||
|
||
var ee = new EventEmitter(); | ||
ee.setMaxListeners(101); | ||
|
||
for (var k = 0; k < 100; k += 1) | ||
ee.on('dummy', function() {}); | ||
|
||
bench.start(); | ||
for (var i = 0; i < n; i += 1) { | ||
var r = ee.listeners('dummy'); | ||
} | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
var common = require('../common.js'); | ||
var EventEmitter = require('events').EventEmitter; | ||
|
||
var bench = common.createBenchmark(main, {n: [25e4]}); | ||
|
||
function main(conf) { | ||
var n = conf.n | 0; | ||
|
||
var 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) { | ||
var r = ee.listeners('dummy'); | ||
} | ||
bench.end(n); | ||
} |