diff --git a/index.js b/index.js index e6c557f..5e977f2 100644 --- a/index.js +++ b/index.js @@ -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); @@ -30,7 +32,18 @@ module.exports = (hermione, opts) => { if (isPromise(res)) { return res.finally(() => log(pluginName, event)) } else { + const start = new Date().getTime(); log(pluginName, event); + const end = new Date().getTime(); + + const id = `${process.pid}:${pluginName}:${event}`; + + if (!DATA[id]) { + DATA[id] = 0; + } + + DATA[id] += end - start; + console.log(`${id}:${DATA[id]}`) } }