Exemplo n.º 1
0
def test_omits_aggregates():
    name = "AllocateDeallocate<Jemalloc>/size:1048576/real_time"
    google_aggregate = {
        "aggregate_name": "mean",
        "cpu_time": 1757.428694267678,
        "iterations": 3,
        "name": "AllocateDeallocate<Jemalloc>/size:1048576/real_time_mean",
        "real_time": 1849.3869337041162,
        "repetitions": 0,
        "run_name": name,
        "run_type": "aggregate",
        "threads": 1,
        "time_unit": "ns",
    }
    google_result = {
        "cpu_time": 1778.6004847419827,
        "iterations": 352765,
        "name": name,
        "real_time": 1835.3137357788837,
        "repetition_index": 0,
        "repetitions": 0,
        "run_name": name,
        "run_type": "iteration",
        "threads": 1,
        "time_unit": "ns",
    }
    archery_result = {
        "counters": {
            "iterations": 352765,
            "repetition_index": 0,
            "repetitions": 0,
            "run_name": name,
            "threads": 1
        },
        "name": name,
        "unit": "ns",
        "less_is_better": True,
        "values": [1835.3137357788837],
        "time_unit": "ns",
        "times": [1835.3137357788837],
    }
    assert google_aggregate["run_type"] == "aggregate"
    assert google_result["run_type"] == "iteration"
    observation1 = GoogleBenchmarkObservation(**google_aggregate)
    observation2 = GoogleBenchmarkObservation(**google_result)
    benchmark = GoogleBenchmark(name, [observation1, observation2])
    result = json.dumps(benchmark, cls=JsonEncoder)
    assert json.loads(result) == archery_result
Exemplo n.º 2
0
def assert_benchmark(name, google_result, archery_result):
    observation = GoogleBenchmarkObservation(**google_result)
    benchmark = GoogleBenchmark(name, [observation])
    result = json.dumps(benchmark, cls=JsonEncoder)
    assert json.loads(result) == archery_result