-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrecommended-number-of-updates.py
executable file
·58 lines (40 loc) · 1.25 KB
/
recommended-number-of-updates.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright © 2016-2017 Martin Ueding <[email protected]>
import argparse
import math
import re
def main():
options = _parse_args()
pattern_update = re.compile(r'Doing Update: (\d+) warm_up_p = \d+')
pattern_total_time = re.compile(r'HMC: total time = ([\d.]+) secs')
updates = []
total_time = None
with open(options.logfile) as f:
for line in f:
m = pattern_update.match(line)
if m:
updates.append(int(m.group(1)))
continue
m = pattern_total_time.match(line)
if m:
total_time = float(m.group(1))
print(updates)
print(total_time)
avg = total_time / len(updates)
for max_wtime in [1.6 * 3600, 5.3 * 3600]:
recommended = math.floor(max_wtime / avg)
print('Recommended:', recommended)
print('Time estimated:', recommended * avg / 3600)
def _parse_args():
'''
Parses the command line arguments.
:return: Namespace with arguments.
:rtype: Namespace
'''
parser = argparse.ArgumentParser(description='')
parser.add_argument('logfile')
options = parser.parse_args()
return options
if __name__ == '__main__':
main()