Skip to content

Commit

Permalink
Added EventEmitter3 to benchmarks;
Browse files Browse the repository at this point in the history
Added platform type output;
Updated README benchmarks section;
  • Loading branch information
DigitalBrainJS committed Apr 19, 2020
1 parent d954ba4 commit 37a5017
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 11 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,15 @@ EventEmitter2 is an implementation of the EventEmitter module found in Node.js.
- Demonstrates good performance in benchmarks

```
EventEmitterHeatUp x 3,728,965 ops/sec \302\2610.68% (60 runs sampled)
EventEmitter x 2,822,904 ops/sec \302\2610.74% (63 runs sampled)
EventEmitter2 x 7,251,227 ops/sec \302\2610.55% (58 runs sampled)
EventEmitter2 (wild) x 3,220,268 ops/sec \302\2610.44% (65 runs sampled)
Platform: win32, x64, 15267MB
Node version: v13.11.0
Cpu: 4 x AMD Ryzen 3 2200U with Radeon Vega Mobile Gfx @ 2495MHz
----------------------------------------------------------------
EventEmitterHeatUp x 3,017,814 ops/sec ±3.37% (68 runs sampled)
EventEmitter x 3,357,197 ops/sec ±4.66% (62 runs sampled)
EventEmitter2 x 11,378,225 ops/sec ±3.99% (62 runs sampled)
EventEmitter2 (wild) x 4,799,373 ops/sec ±4.01% (66 runs sampled)
EventEmitter3 x 10,007,114 ops/sec ±3.94% (69 runs sampled)
Fastest is EventEmitter2
```

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
"repository": "git://github.com/hij1nx/EventEmitter2.git",
"devDependencies": {
"benchmark": "^2.1.4",
"bluebird": "^3.7.2",
"coveralls": "^3.0.11",
"mocha": "^7.1.1",
"nodeunit": "*",
"nyc": "^15.0.0",
"bluebird": "^3.7.2"
"nyc": "^15.0.0"
},
"main": "./lib/eventemitter2.js",
"scripts": {
Expand Down
44 changes: 39 additions & 5 deletions test/perf/benchmark.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
var os= require('os');


var Benchmark = require('benchmark');
var suite = new Benchmark.Suite();
Expand All @@ -8,16 +10,42 @@ var emitter = new EventEmitter;
var EventEmitter2 = require('../../lib/eventemitter2').EventEmitter2;
var emitter2 = new EventEmitter2;

var EventEmitter3 = require('events').EventEmitter;
var EventEmitterB = require('events').EventEmitter;
var emitterB = new EventEmitterB;

var EventEmitter3 = require('eventemitter3').EventEmitter;
var emitter3 = new EventEmitter3;

suite
console.log('Platform: ' + [
process.platform,
process.arch,
Math.round((os.totalmem() / (1024 * 1024))) + 'MB'
].join(', '));

console.log('Node version: ' + process.version);
var cpus= {};
os.cpus().forEach(function(cpu){
var id= [cpu.model.trim(), ' @ ', cpu.speed, 'MHz'].join('');
if(!cpus[id]){
cpus[id]= 1;
}else{
cpus[id]++;
}
});

console.log('Cpu:' + Object.entries(cpus).map(function([cpu, count]){
return [' ', count, ' x ', cpu].join('');
}).join('\n'));

console.log('----------------------------------------------------------------');

suite

.add('EventEmitterHeatUp', function() {

emitter3.on('test3', function () { 1==1; });
emitter3.emit('test3');
emitter3.removeAllListeners('test3');
emitterB.on('test3', function () { 1==1; });
emitterB.emit('test3');
emitterB.removeAllListeners('test3');

})
.add('EventEmitter', function() {
Expand All @@ -43,6 +71,12 @@ suite

})

.add('EventEmitter3', function() {
emitter3.on('test2', function () { 1==1; });
emitter3.emit('test2');
emitter3.removeAllListeners('test2');
})

.on('cycle', function(event, bench) {
console.log(String(event.target));
})
Expand Down
16 changes: 16 additions & 0 deletions test/perf/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "benchmarks",
"version": "0.0.0",
"description": "eventemitter3 benchmarks",
"main": "index.js",
"scripts": {
"benchmark": "find run -name '*.js' -exec ./start.sh {} \\;"
},
"repository": "primus/eventemitter3",
"author": "Arnout Kazemier",
"license": "MIT",
"dependencies": {
"benchmark": "2.1.x",
"eventemitter3": "latest"
}
}

0 comments on commit 37a5017

Please sign in to comment.