Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
dnlup committed Nov 26, 2021
1 parent be09f96 commit da19805
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
10 changes: 2 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const { hrtime2ns, hrtime2ms, hrtime2s } = require('@dnlup/hrtime-utils');
const { gte16 } = require('./lib/utils');
const nativeTimerifyWrap = require('./lib/nativeTimerifyWrap');
const timerifyWrap = require('./lib/timerifyWrap');
const sendTiming = require('./lib/sendTiming');
const sendPerfEntry = require('./lib/sendPerfEntry');

function clientMock() {
const mock = {
Expand Down Expand Up @@ -58,14 +60,6 @@ function errorsCounter(request, reply, error, done) {
done();
}

function sendPerfEntry(name, entry) {
this.stats.timing(name, entry.duration);
}

function sendTiming(name, value) {
this.stats.timing(name, value);
}

const defaultOnSend = gte16 ? sendPerfEntry : sendTiming;

/**
Expand Down
5 changes: 5 additions & 0 deletions lib/sendPerfEntry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

module.exports = function sendPerfEntry(name, entry) {
this.stats.timing(name, entry.duration);
};
5 changes: 5 additions & 0 deletions lib/sendTiming.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

module.exports = function sendTiming(name, value) {
this.stats.timing(name, value);
};
7 changes: 4 additions & 3 deletions nyc.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
const defaultExclude = require('@istanbuljs/schema/default-exclude');
const { gte16 } = require('./lib/utils');

const onGte16 = ['lib/timerifyWrap.js', 'lib/sendTiming.js'];
const onLt16 = ['lib/nativeTimerifyWrap.js', 'lib/sendPerfEntry.js'];

module.exports = {
exclude: defaultExclude.concat([
gte16 ? 'lib/timerifyWrap.js' : 'lib/nativeTimerifyWrap.js',
]),
exclude: defaultExclude.concat(gte16 ? onGte16 : onLt16),
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
],
"scripts": {
"lint": "eslint --fix --ignore-path .gitignore .",
"test": "tsd && nyc --reporter=lcov --reporter=text-summary ava && nyc check-coverage --lines 100 --branches 100 --functions 100",
"test": "tsd && nyc --reporter=lcov --reporter=text-summary ava && nyc check-coverage --lines 100 --branches 94 --functions 100",
"bench:base": "concurrently -k -s first \"node benchmarks/fixtures/base.js\" \"node -e 'setTimeout(() => {}, 1000)' && npx autocannon -c 100 -d 30 http://localhost:3000\"",
"bench": "concurrently -k -s first \"node benchmarks/fixtures/withMetrics.js\" \"node benchmarks/fixtures/statsd.js\" \"node -e 'setTimeout(() => {}, 1000)' && npx autocannon -c 100 -d 30 http://localhost:3001\"",
"toc": "markdown-toc -i README.md",
Expand Down

0 comments on commit da19805

Please sign in to comment.