UNPKG

since-app-start

Version:

Get time passed since node.js app start. Similar to performance.now() from browsers.

23 lines (19 loc) 450 B
'use strict'; const startTime = global[Symbol.for('start-time')] || Date.now(); const profilings = Object.create(null); const debug = require('debug')('speed'); const addEntry = name => { const ms = Date.now() - startTime; profilings[name] = ms; return `${name} ${ms} ms`; }; module.exports = { profilings, addEntry, profile(name) { return debug(addEntry(name)); }, get sinceStart() { return Date.now() - startTime; } };