-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot.py
More file actions
47 lines (40 loc) · 1.07 KB
/
plot.py
File metadata and controls
47 lines (40 loc) · 1.07 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
from sys import argv
import matplotlib.pyplot as plt
import numpy as np
from glob import glob
from tqdm import tqdm
def plot_figure(errs, sample_nums, plot_filename, ylim):
median = errs[-1]
err = errs[:-1]
plt.figure()
if len(sample_nums) > len(err):
sample_nums = sample_nums[:-1]
plt.plot(sample_nums, err)
avg = np.mean(err)
p99 = np.percentile(err, 90)
plt.axhline(median, color='k', linestyle='dashed', label='median')
if ylim > 0:
plt.ylim((0,ylim))
else:
plt.ylim(bottom=0)
_, max_x = plt.xlim()
_, max_y = plt.ylim()
plt.text(10, max_y,
'p90: {:.2f}\n median delta-t: {}'.format(p99, median))
plt.xlabel('Progression of trace')
plt.ylabel('Error in microseconds')
plt.savefig(plot_filename)
plt.close()
def main():
directory = argv[1]
ylim = int(argv[2])
if directory[-1] != '/':
directory += '/'
files = glob(directory + '*.npz')
for file in tqdm(files):
plot_filename = file[:-3] + 'png'
npfile = np.load(file)
errs = npfile['err']
sample_nums = npfile['sample_num']
plot_figure(errs, sample_nums, plot_filename, ylim)
main()