Fix Flake8 errors
[integration/test.git] / tools / odl-mdsal-clustering-tests / clustering-performance-test / create_plot_data_files.py
1 #!/usr/bin/python
2 import re
3
4 text_file = open("out.log.txt", "r")
5 log = text_file.read()
6 text_file.close()
7
8 rate = []
9 time = []
10
11 pat_rate = re.compile(r'Avg. requests/s: (?P<rate1>[0-9,\.]+) OK, (?P<rate2>[0-9,\.]+) Total')
12 pat_time = re.compile(r'Stats collected in (?P<time1>[0-9,\.]+) seconds')
13
14 for line in log.splitlines():
15     res = pat_rate.search(line)
16     if res is not None:
17         rate.append(res.groups('rate1')[0])
18 print(rate)
19
20 for line in log.splitlines():
21     res = pat_time.search(line)
22     if res is not None:
23         time.append(res.groups('time1')[0])
24 print(time)
25
26 text_file = open("rates.csv", "w")
27 text_file.write('Add,Delete\n')
28 text_file.write('{0},{1}\n'.format(rate[0], rate[1]))
29 text_file.close()
30
31 text_file = open("times.csv", "w")
32 text_file.write('Add,Delete\n')
33 text_file.write('{0},{1}\n'.format(time[0], time[1]))
34 text_file.close()