mirror of
https://github.com/neondatabase/neon.git
synced 2025-12-23 06:09:59 +00:00
pagebench-based GetPage@LSN performance test (#6214)
This commit is contained in:
committed by
GitHub
parent
a72af29d12
commit
996abc9563
@@ -397,3 +397,36 @@ def run_pg_bench_small(pg_bin: "PgBin", connstr: str):
|
||||
}
|
||||
"""
|
||||
pg_bin.run(["pgbench", "-i", "-I dtGvp", "-s1", connstr])
|
||||
|
||||
|
||||
def humantime_to_ms(humantime: str) -> float:
|
||||
"""
|
||||
Converts Rust humantime's output string to milliseconds.
|
||||
|
||||
humantime_to_ms("1h 1ms 406us") -> 3600001.406
|
||||
"""
|
||||
|
||||
unit_multiplier_map = {
|
||||
"ns": 1e-6,
|
||||
"us": 1e-3,
|
||||
"ms": 1,
|
||||
"s": 1e3,
|
||||
"m": 1e3 * 60,
|
||||
"h": 1e3 * 60 * 60,
|
||||
}
|
||||
matcher = re.compile(rf"^(\d+)({'|'.join(unit_multiplier_map.keys())})$")
|
||||
total_ms = 0.0
|
||||
|
||||
if humantime == "0":
|
||||
return total_ms
|
||||
|
||||
for item in humantime.split():
|
||||
if (match := matcher.search(item)) is not None:
|
||||
n, unit = match.groups()
|
||||
total_ms += int(n) * unit_multiplier_map[unit]
|
||||
else:
|
||||
raise ValueError(
|
||||
f"can't parse '{item}' (from string '{humantime}'), known units are {', '.join(unit_multiplier_map.keys())}."
|
||||
)
|
||||
|
||||
return round(total_ms, 3)
|
||||
|
||||
Reference in New Issue
Block a user