File: extract_benchmark_data.py

package info (click to toggle)
sphinx-needs 5.1.0%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 12,108 kB
  • sloc: python: 21,148; javascript: 187; makefile: 95; sh: 29; xml: 10
file content (32 lines) | stat: -rw-r--r-- 937 bytes parent folder | download
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
import json
import sys


def extract(input_file, output_file):
    with open(input_file) as in_file:
        input_data = json.load(in_file)

    data = []

    for bench in input_data["benchmarks"]:
        name = bench["name"].split("[")[0]
        if name == "test_basic_time":
            name = "Small, basic Sphinx-Needs project"
        elif name == "test_official_time":
            name = "Official Sphinx-Needs documentation (without services)"

        output = {
            "name": name,
            "unit": "s",
            "value": bench["stats"]["mean"],
            "extra": f"Commit: {input_data['commit_info']['id']}\nBranch: {input_data['commit_info']['branch']}\
\nTime: {input_data['commit_info']['time']}",
        }
        data.append(output)

    with open(output_file, "w") as out_file:
        json.dump(data, out_file, sort_keys=True, indent=4)


if "main" in __name__:
    extract(sys.argv[1], sys.argv[2])