Skip to content

Commit

Permalink
feat: display more detailed total time to include hours, mins and sec…
Browse files Browse the repository at this point in the history
…onds
  • Loading branch information
razonyang committed Jun 15, 2024
1 parent 43c1704 commit f7933ce
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,19 @@ class Metrics {
}

duration (): string {
if (this.time > 3600 * 10e2) {
return `${blue(this.time / 3600 / 10e2)} h`
} else if (this.time > 60 * 10e2) {
return `${blue(this.time / 60 / 10e2)} min`
const h = Math.floor(this.time / (10e2 * 3600))
const m = Math.floor(this.time / (10e2 * 60) % 60)
const s = (this.time / 10e2 % 60)
let v = `${green(s)}s`

if (m > 0) {
v = `${blue(m)}m` + v
}
if (h > 0) {
v = `${yellow(h)}h` + v
}

return `${blue(this.time / 10e2)} s`
return v
}

speed (): string {
Expand Down

0 comments on commit f7933ce

Please sign in to comment.