mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
lib: create diagnostics_channel module
PR-URL: https://github.com/nodejs/node/pull/34895 Reviewed-By: Bryan English <bryan@bryanenglish.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: Michael Dawson <midawson@redhat.com>
This commit is contained in:
1 parent
5dd344a2a8
commit
c6c36c3da7
10 files changed
+444
No files matched your search
@@ -0,0 +1,29 @@
|
||||
'use strict';
|
||||
const common = require('../common.js');
|
||||
const dc = require('diagnostics_channel');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e8],
|
||||
subscribers: [0, 1, 10],
|
||||
});
|
||||
|
||||
function noop() {}
|
||||
|
||||
function main({ n, subscribers }) {
|
||||
const channel = dc.channel('test');
|
||||
for (let i = 0; i < subscribers; i++) {
|
||||
channel.subscribe(noop);
|
||||
}
|
||||
|
||||
const data = {
|
||||
foo: 'bar'
|
||||
};
|
||||
|
||||
bench.start();
|
||||
for (let i = 0; i < n; i++) {
|
||||
if (channel.hasSubscribers) {
|
||||
channel.publish(data);
|
||||
}
|
||||
}
|
||||
bench.end(n);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
'use strict';
|
||||
const common = require('../common.js');
|
||||
const dc = require('diagnostics_channel');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e8],
|
||||
});
|
||||
|
||||
function noop() {}
|
||||
|
||||
function main({ n }) {
|
||||
const channel = dc.channel('channel.0');
|
||||
|
||||
bench.start();
|
||||
for (let i = 0; i < n; i++) {
|
||||
channel.subscribe(noop);
|
||||
}
|
||||
bench.end(n);
|
||||
}
|
||||
Reference in new issue
Block a user