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