Belle II Software  release-05-01-25
evaluation.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 import numpy as np
5 
6 
7 def fFileExist(filename):
8  '''Test if file exists'''
9 
10  try:
11  oFile = open(filename, 'r')
12  except IOError:
13  return 0
14  else:
15  oFile.close()
16  return 1
17 
18 
19 def read(optlevel):
20  '''read time from output files'''
21 
22  filename = 'output/output-' + optlevel + '.dat'
23  if fFileExist(filename) == 0:
24  print('missing ' + filename)
25  else:
26  CDCLegendreTracking = []
27  fobj = open(filename, 'r')
28  # read output file
29  for line in fobj:
30  if line.startswith('CDCLegendreTracking'):
31  words = line.split()
32  CDCLegendreTracking.append(float(words[6]))
33  fobj.close()
34  print(optlevel + ' read')
35  # write CDCLegendreTracking times
36  fobj = open('out/' + optlevel + '.out', 'w')
37  for i in range(0, len(CDCLegendreTracking)):
38  fobj.write(str(CDCLegendreTracking[i]) + '\n')
39  i = i + 1
40  fobj.close()
41 
42 
43 optlevel = ['gcc-O0', 'gcc-O3', 'gcc-O3-native']
44 for i in optlevel:
45  read(i)