Skip to content

Commit

Permalink
dev
Browse files Browse the repository at this point in the history
  • Loading branch information
eGavr committed Feb 24, 2020
1 parent 0074a3b commit b3bbfbb
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const parseConfig = require('./config');

const UNKNOWN_PLUGIN_NAME = 'unknown-plugin-name';

const DATA = {};

module.exports = (hermione, opts) => {
const config = parseConfig(opts);

Expand All @@ -25,12 +27,22 @@ module.exports = (hermione, opts) => {
const fn = (...args) => {
log(pluginName, event)

const start = new Date().getTime();
const res = cb(...args);
const end = new Date().getTime();

if (isPromise(res)) {
return res.finally(() => log(pluginName, event))
} else {
log(pluginName, event);
const id = `${process.pid}:${pluginName}:${event}`;

if (!DATA[id]) {
DATA[id] = 0;
}

DATA[id] += end - start;
console.log(`${id}:${DATA[id]}`)
}
}

Expand Down

0 comments on commit b3bbfbb

Please sign in to comment.