47 lines
2.6 KiB
JavaScript
47 lines
2.6 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.HrtMeasurement = void 0;
|
|
/**
|
|
* 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnR0aW1lLmNsYXNzZXMuaHJ0bWVhc3VyZW1lbnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHRpbWUuY2xhc3Nlcy5ocnRtZWFzdXJlbWVudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQTs7R0FFRztBQUNILE1BQWEsY0FBYztJQUEzQjtRQUNTLGdCQUFXLEdBQVcsSUFBSSxDQUFDO1FBQzNCLGlCQUFZLEdBQVcsSUFBSSxDQUFDO1FBQzNCLGlCQUFZLEdBQU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