mirror of
https://github.com/alexankitty/Myrient-Search-Engine.git
synced 2026-01-15 08:23:18 -03:00
19 lines
575 B
JavaScript
19 lines
575 B
JavaScript
export class Timer {
|
|
constructor() {
|
|
this.startTime = process.hrtime();
|
|
}
|
|
parseHrtimetoSeconds(hrtime) {
|
|
var seconds = (hrtime[0] + hrtime[1] / 1e9).toFixed(3);
|
|
return seconds;
|
|
}
|
|
elapsed() {
|
|
let elapsed = this.parseHrtimetoSeconds(process.hrtime(this.startTime));
|
|
let h = Math.floor(elapsed / 3600);
|
|
let m = Math.floor((elapsed / 60) % 60);
|
|
let s = Math.floor(elapsed % 60);
|
|
return `${h ? h + "h" : ""}${m ? m + "m" : ""}${s + "s"}`;
|
|
}
|
|
elapsedSeconds(){
|
|
return this.parseHrtimetoSeconds(process.hrtime(this.startTime));
|
|
}
|
|
} |