| •1 |
def pytest_benchmark_update_json(config, benchmarks, output_json): |
| 2 |
"""Calculate compression/decompression speed and add as extra_info""" |
| 3 |
for benchmark in output_json["benchmarks"]: |
| 4 |
if "data_size" in benchmark["extra_info"]: |
| 5 |
rate = benchmark["extra_info"].get("data_size", 0.0) / benchmark["stats"]["mean"] |
| 6 |
benchmark["extra_info"]["rate"] = rate |
| 7 |
|
| 8 |
|
| 9 |
def pytest_benchmark_update_machine_info(config, machine_info): |
| •10 |
import cpuinfo |
| 11 |
cpu_info = cpuinfo.get_cpu_info() |
| 12 |
brand = cpu_info.get("brand_raw", None) |
| 13 |
if brand is None: |
| 14 |
brand = "{} core(s) {} CPU ".format(cpu_info.get("count", "unknown"), cpu_info.get("arch", "unknown")) |
| 15 |
machine_info["cpu"]["brand"] = brand |
| 16 |
machine_info["cpu"]["hz_actual_friendly"] = cpu_info.get("hz_actual_friendly", "unknown") |