File: performance-plot.py

package info (click to toggle)
timew 1.4.2%2Bds.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 3,060 kB
  • sloc: cpp: 27,588; python: 6,095; sh: 642; makefile: 15
file content (34 lines) | stat: -rwxr-xr-x 1,067 bytes parent folder | download | duplicates (2)
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
33
34
#!/usr/bin/env python3
import argparse
import os

import matplotlib.pyplot as plt
import numpy as np

parser = argparse.ArgumentParser(description='Display performance plots.')
parser.add_argument('output_dir',
                    help='directory containing the measurement files')

args = parser.parse_args()

output_directory = args.output_dir

plt.axes([0.1, 0.1, 0.6, 0.75])
plt.xlabel("# database entries")
plt.ylabel("time [s]")
plt.title("timew performance")

for filename in os.listdir(output_directory):
    if filename.endswith(".log"):
        cmd = "-".join(filename.split('-')[1:-1])
        try:
            x, y = np.loadtxt(os.path.join(output_directory, filename),
                              delimiter='\t',
                              usecols=(1, 2),
                              unpack=True)
            plt.plot(x, y, label=cmd, marker=".", linestyle='')
        except ValueError as e:
            print("Invalid file: {} {}".format(filename, e))

plt.legend(bbox_to_anchor=(1.05, 1), loc='upper left', borderaxespad=0., ncol=2)
plt.show()