early/dist/index.js

54 lines
3.8 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("typings-global");
const beautycolor = require("beautycolor");
const smartq = require("smartq");
const process = require("process");
let doText = false;
let moduleName = 'undefined module name';
let startTime = Date.now();
if (process.argv.indexOf('-v') === -1) {
doText = true;
}
/**
* start the loading
*/
exports.start = function (moduleNameArg = '', loaderLengthArg = '10') {
moduleName = moduleNameArg;
if (doText) {
console.log(`**** starting ${beautycolor.coloredString(moduleNameArg, 'green')} ****`);
}
};
exports.stop = () => {
let done = smartq.defer();
let endTime = Date.now();
let earlyExecutionTime = (endTime - startTime);
let earlyExecutionTimeString = (earlyExecutionTime / 1000).toString();
console.log(`OK! -> finished loading within ${beautycolor.coloredString(earlyExecutionTimeString, 'blue')}`);
done.resolve(earlyExecutionTime);
return done.promise;
};
class hrtMeasurement {
constructor() {
this._started = false;
}
start() {
this._started = true;
this._hrTimeStart = process.hrtime();
}
stop() {
if (this._started === false) {
console.log('Hasn\'t started yet');
return;
}
let diffTime = process.hrtime(this._hrTimeStart);
let nanoSeconds = (diffTime[0] * 1e9) + diffTime[1];
let milliSeconds = nanoSeconds / 1000000;
return {
nanoSeconds: nanoSeconds,
milliSeconds: milliSeconds
};
}
}
exports.hrtMeasurement = hrtMeasurement;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDBCQUF1QjtBQUN2QiwyQ0FBMEM7QUFDMUMsaUNBQWdDO0FBQ2hDLG1DQUFrQztBQUVsQyxJQUFJLE1BQU0sR0FBWSxLQUFLLENBQUE7QUFDM0IsSUFBSSxVQUFVLEdBQVcsdUJBQXVCLENBQUE7QUFDaEQsSUFBSSxTQUFTLEdBQUcsSUFBSSxDQUFDLEdBQUcsRUFBRSxDQUFBO0F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