From b3bbfbbd5849506deb3b50a2208eba52104a314d Mon Sep 17 00:00:00 2001 From: Evgeniy Gavryushin Date: Mon, 24 Feb 2020 12:49:07 +0300 Subject: [PATCH] dev --- index.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/index.js b/index.js index e6c557f..28bf138 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); @@ -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]}`) } }