forked from DOMjudge/domjudge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshowtimedata.py
36 lines (29 loc) · 903 Bytes
/
showtimedata.py
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
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy as np
from os import walk
from matplotlib import rcParams
rcParams.update({'figure.autolayout': True})
from matplotlib.pyplot import figure
figure(figsize=(16, 6), dpi=80)
begin = []
end = []
event = []
mypath = 'duration'
filenames = next(walk(mypath), (None, None, []))[2] # [] if no file
for f in filenames:
event.append(f)
with open(f"{mypath}/{f}",'r') as fp:
for line in fp.readlines():
if 'job_begin' in line:
begin.append(int(line.split(' ')[1]))
elif 'job_end' in line:
end.append(int(line.split(' ')[1]))
offset = min(begin)
begin = np.array(begin)-offset
end = np.array(end)-offset
plt.barh(range(len(begin)), end-begin, left=begin)
plt.xlim([-10,max(end)+10])
plt.yticks(range(len(begin)), event)
plt.savefig('time.png')