2020-08-02 18:03:21 +01:00
|
|
|
from typing import Optional
|
|
|
|
|
|
|
|
|
2020-06-25 18:35:01 +01:00
|
|
|
def bandwidth_text(bandwidth: int) -> str:
|
|
|
|
size = {0: "bps", 1: "Kbps", 2: "Mbps", 3: "Gbps"}
|
|
|
|
unit = 1000
|
|
|
|
i = 0
|
|
|
|
while bandwidth > unit:
|
|
|
|
bandwidth /= unit
|
|
|
|
i += 1
|
|
|
|
if i == 3:
|
|
|
|
break
|
|
|
|
return f"{bandwidth} {size[i]}"
|
2020-08-02 18:03:21 +01:00
|
|
|
|
|
|
|
|
|
|
|
def delay_jitter_text(delay: int, jitter: int) -> Optional[str]:
|
|
|
|
line = None
|
|
|
|
if delay > 0 and jitter > 0:
|
|
|
|
line = f"{delay} us (\u00B1{jitter} us)"
|
|
|
|
elif jitter > 0:
|
|
|
|
line = f"0 us (\u00B1{jitter} us)"
|
|
|
|
return line
|