diff options
author | Benedikt Meurer <bmeurer@google.com> | 2017-07-03 12:52:37 +0300 |
---|---|---|
committer | Matteo Collina <hello@matteocollina.com> | 2017-07-05 14:14:13 +0300 |
commit | 0011eb28cf56deedba9c3e61865554aa19a63b9e (patch) | |
tree | b77144baf699fd0f2a8f97d2f2973f4a65d00854 /benchmark/events/ee-add-remove.js | |
parent | 6e86a70da2f54bd68cc5a8038a5d6940d6a4fce9 (diff) |
benchmark: Improve event performance tests.
Currently most of the event tests only test a single event type,
which might let those benchmark take fast-paths (in V8) that aren't
taken in realistic use cases, and thus the benchmarks are not good
proxies of real world uses.
PR-URL: https://github.com/nodejs/node/pull/14052
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Diffstat (limited to 'benchmark/events/ee-add-remove.js')
-rw-r--r-- | benchmark/events/ee-add-remove.js | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/benchmark/events/ee-add-remove.js b/benchmark/events/ee-add-remove.js index 99d85367cb8..1140a81649f 100644 --- a/benchmark/events/ee-add-remove.js +++ b/benchmark/events/ee-add-remove.js @@ -16,10 +16,13 @@ function main(conf) { bench.start(); for (var i = 0; i < n; i += 1) { - for (k = listeners.length; --k >= 0; /* empty */) - ee.on('dummy', listeners[k]); - for (k = listeners.length; --k >= 0; /* empty */) - ee.removeListener('dummy', listeners[k]); + var dummy = (i % 2 === 0) ? 'dummy0' : 'dummy1'; + for (k = listeners.length; --k >= 0; /* empty */) { + ee.on(dummy, listeners[k]); + } + for (k = listeners.length; --k >= 0; /* empty */) { + ee.removeListener(dummy, listeners[k]); + } } bench.end(n); } |