aboutsummaryrefslogtreecommitdiff
path: root/fixup-perf-csv.py
blob: 338dd33dd18aa4b3f4a0a3a075aae586044363f9 (plain)
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
#!/usr/bin/python3

import sys
import pandas as pd

# The script does the following:
# (a) If dso is not present in perf.csv, it adds a dummy dso column.
# (b) We don't have dso entry present for binary and libraries, so create a dummy one.
# (c) Strip whitespace in dso name.

def main():
    assert len(sys.argv) == 2
    df = pd.read_csv(sys.argv[1])
    if "dso" not in list(df.columns.values):
        df["dso"] = "na"
    df = df.fillna("na")
    df["dso"] = df["dso"].str.strip()
    # When all benchmarks have failed, perf.csv is empty, and this messes up
    # order of columns while merging. Rearrange the columns to "expected order"
    # with benchmark,symbol appearing first.
    # The order of columns shouldn't really be an issue, but we need
    # (or needed at some point) for benchmark to be the first metric, and thus
    # assert for it in merge-metric-csvs.py. This needs to be re-checked after
    # we move away from csvs2table.py.
    df = df[["benchmark", "symbol", "sample", "dso"]]
    df.to_csv(sys.stdout, index=False)

if __name__ == "__main__":
    main()