aboutsummaryrefslogtreecommitdiffhomepage
path: root/benchmarks/by-n/plot.py
blob: ba96a0cffbd282c716353fcfbc750dde4c71ea22 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/env python3

import matplotlib.pyplot as plt
import json
import os, glob


def render(file):
    data = json.load(open(file, "r"))["results"]
    basename = os.path.basename(file).split(".")[0]
    reducers = list({p["parameters"]["REDUCER"] for p in data})
    for reducer in reducers:
        labels = [
            p["parameters"]["N"]
            for p in data
            if p["parameters"]["REDUCER"] == reducer
        ]
        times = [
            p["median"] for p in data if p["parameters"]["REDUCER"] == reducer
        ]
        plt.plot(times)
        plt.xticks(range(len(labels)), labels)
    plt.legend(reducers)
    plt.title(f"reducer comparison for {basename}")
    plt.xlabel("N")
    plt.ylabel("Time (s)")
    plt.savefig(f"{basename}.png")
    plt.close()


for file in glob.glob("*.json"):
    render(file)