MCPcopy Create free account
hub / github.com/cli99/llm-analysis / _latency_to_string

Function _latency_to_string

llm_analysis/utils.py:31–50  ·  view source on GitHub ↗
(latency_in_s, precision=2)

Source from the content-addressed store, hash-verified

29
30
31def _latency_to_string(latency_in_s, precision=2):
32 if latency_in_s is None:
33 return "None"
34 day = 24 * 60 * 60
35 hour = 60 * 60
36 minute = 60
37 ms = 1 / 1000
38 us = 1 / 1000000
39 if latency_in_s // day > 0:
40 return str(round(latency_in_s / day, precision)) + " days"
41 elif latency_in_s // hour > 0:
42 return str(round(latency_in_s / hour, precision)) + " hours"
43 elif latency_in_s // minute > 0:
44 return str(round(latency_in_s / minute, precision)) + " minutes"
45 elif latency_in_s > 1:
46 return str(round(latency_in_s, precision)) + " s"
47 elif latency_in_s > ms:
48 return str(round(latency_in_s / ms, precision)) + " ms"
49 else:
50 return str(round(latency_in_s / us, precision)) + " us"
51
52
53def within_range(val, target, tolerance):

Callers 3

test_training_mt_nlg_2Function · 0.90

Calls

no outgoing calls

Tested by 2

test_training_mt_nlg_2Function · 0.72