Skip to content

Commit 5f9bf52

Browse files
committed
handle days
1 parent 113f59d commit 5f9bf52

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

codeflash/code_utils/time_utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ def humanize_runtime(time_in_ns: int) -> str:
2424
runtime_human = "%.3g" % (time_micro / (1000**2))
2525
elif units in {"minutes", "minute"}:
2626
runtime_human = "%.3g" % (time_micro / (60 * 1000**2))
27-
else: # hours
27+
elif units in {"hour", "hours"}: #hours
2828
runtime_human = "%.3g" % (time_micro / (3600 * 1000**2))
29-
29+
else: #days
30+
runtime_human = "%.3g" % (time_micro / (24*3600 * 1000**2))
3031
runtime_human_parts = str(runtime_human).split(".")
3132
if len(runtime_human_parts[0]) == 1:
3233
if len(runtime_human_parts) == 1:

tests/test_humanize_time.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,5 @@ def test_humanize_runtime():
2525
assert humanize_runtime(123456789123) == "2.06 minutes"
2626
assert humanize_runtime(1234567891234) == "20.6 minutes"
2727
assert humanize_runtime(12345678912345) == "3.43 hours"
28+
assert humanize_runtime(98765431298760) == "1.14 day"
29+
assert humanize_runtime(197530862597520) == "2.29 days"

0 commit comments

Comments
 (0)