47 lines
2.7 KiB
JavaScript
47 lines
2.7 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const process = require("process");
|
|
/**
|
|
* easy high resolution time measurement
|
|
*/
|
|
class HrtMeasurement {
|
|
constructor() {
|
|
this.nanoSeconds = null;
|
|
this.milliSeconds = null;
|
|
this._hrTimeStart = null;
|
|
this._hrTimeStopDiff = null;
|
|
this._started = false;
|
|
}
|
|
/**
|
|
* start the measurement
|
|
*/
|
|
start() {
|
|
this._started = true;
|
|
this._hrTimeStart = process.hrtime();
|
|
}
|
|
/**
|
|
* stop the measurement
|
|
*/
|
|
stop() {
|
|
if (this._started === false) {
|
|
console.log("Hasn't started yet");
|
|
return;
|
|
}
|
|
this._hrTimeStopDiff = process.hrtime(this._hrTimeStart);
|
|
this.nanoSeconds = this._hrTimeStopDiff[0] * 1e9 + this._hrTimeStopDiff[1];
|
|
this.milliSeconds = this.nanoSeconds / 1000000;
|
|
return this;
|
|
}
|
|
/**
|
|
* reset the measurement
|
|
*/
|
|
reset() {
|
|
this.nanoSeconds = null;
|
|
this.milliSeconds = null;
|
|
this._hrTimeStart = null;
|
|
this._hrTimeStopDiff = null;
|
|
this._started = false;
|
|
}
|
|
}
|
|
exports.HrtMeasurement = HrtMeasurement;
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnR0aW1lLmNsYXNzZXMuaHJ0bWVhc3VyZW1lbnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHRpbWUuY2xhc3Nlcy5ocnRtZWFzdXJlbWVudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLG1DQUFtQztBQUVuQzs7R0FFRztBQUNIO0lBQUE7UUFDRSxnQkFBVyxHQUFXLElBQUksQ0FBQztRQUMzQixpQkFBWSxHQUFXLElBQUksQ0FBQztRQUNwQixpQkFBWSxHQUFHLElBQUksQ0FBQzt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