|
| 1 | +from pathlib import Path |
| 2 | + |
| 3 | +import pytest |
| 4 | + |
| 5 | +from cloudai.workloads.nixl_bench.report_generation_strategy import extract_data |
| 6 | + |
| 7 | +LEGACY_FORMAT = """ |
| 8 | +Block Size (B) Batch Size Avg Lat. (us) B/W (MiB/Sec) B/W (GiB/Sec) B/W (GB/Sec) |
| 9 | +-------------------------------------------------------------------------------- |
| 10 | +4096 1 21.1726 184.495 0.180171 0.193457 |
| 11 | +8192 1 21.7391 359.376 0.350953 0.376833 |
| 12 | +33554432 1 24.6508 1.29813e+06 1267.71 1361.19 |
| 13 | +67108864 1 39.746 1.61022e+06 1572.48 1688.44 |
| 14 | +""" |
| 15 | + |
| 16 | +NEW_FORMAT = """ |
| 17 | +Block Size (B) Batch Size B/W (GB/Sec) Avg Lat. (us) Avg Prep (us) P99 Prep (us) Avg Post (us) P99 Post (us) Avg Tx (us) P99 Tx (us) |
| 18 | +---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 19 | +4096 1 0.958841 4.3 11.0 11.0 0.8 1.0 3.5 4.0 |
| 20 | +8192 1 1.745779 4.7 13.0 13.0 0.8 1.0 3.8 5.0 |
| 21 | +33554432 1 23.506385 1427.5 13.0 13.0 1.0 9.0 1426.0 1446.0 |
| 22 | +67108864 1 23.582432 2845.7 13.0 13.0 0.9 9.0 2844.5 2851.0 |
| 23 | +""" |
| 24 | + |
| 25 | + |
| 26 | +@pytest.mark.parametrize( |
| 27 | + "sample,exp_latency,exp_bw", |
| 28 | + [ |
| 29 | + (LEGACY_FORMAT, [21.1726, 21.7391, 24.6508, 39.746], [0.193457, 0.376833, 1361.19, 1688.44]), |
| 30 | + (NEW_FORMAT, [4.3, 4.7, 1427.5, 2845.7], [0.958841, 1.745779, 23.506385, 23.582432]), |
| 31 | + ], |
| 32 | + ids=["LegacyFormat", "NewFormat"], |
| 33 | +) |
| 34 | +def test_nixl_bench_report_parsing(tmp_path: Path, sample: str, exp_latency: list[float], exp_bw: list[float]): |
| 35 | + (tmp_path / "nixl_bench.log").write_text(sample) |
| 36 | + df = extract_data(tmp_path / "nixl_bench.log") |
| 37 | + assert df.shape == (4, 4) |
| 38 | + assert df["block_size"].tolist() == [4096, 8192, 33554432, 67108864] |
| 39 | + assert df["batch_size"].tolist() == [1, 1, 1, 1] |
| 40 | + assert df["avg_lat"].tolist() == exp_latency |
| 41 | + assert df["bw_gb_sec"].tolist() == exp_bw |
0 commit comments