xref: /petsc/src/benchmarks/streams/process.py (revision 6a90b7350c6b50a97f07457f08ffbd37ff239369)
1#!/usr/bin/env python
2#!/bin/env python
3#
4#    Computers speed up of Streams benchmark results generated by make streams
5#
6import os
7#
8def process():
9  import re
10  ff = open('output')
11  data = ff.read()
12  ff.close()
13
14  hosts  = {}
15  triads = {}
16  speedups = {}
17  match = data.split('Number of MPI processes ')
18  for i in match:
19    if i:
20      fields = i.split('\n')
21      size = int(fields[0])
22      hosts[size] = fields[1:size+1]
23      triads[size] = float(fields[size+5].split()[1])
24
25  ff = open('output','a')
26  print 'np  speedup'
27  ff.write('np  speedup\n')
28  for sizes in hosts:
29    speedups[sizes] = triads[sizes]/triads[1]
30    print sizes,round(triads[sizes]/triads[1],2)
31    ff.write(str(sizes)+' '+str(round(triads[sizes]/triads[1],2))+'\n')
32  ff.close()
33
34  try:
35    import matplotlib
36  except:
37    print "Unable to open matplotlib to plot speedup"
38    return
39
40  try:
41    import matplotlib.pyplot as plt
42  except:
43    print "Unable to open matplotlib to plot speedup"
44    return
45
46  try:
47    plt.title('Perfect and Streams Speedup')
48    plt.plot(hosts.keys(),hosts.keys(),'b-o',hosts.keys(),speedups.values(),'r-o')
49    plt.show()
50  except:
51    print "Unable to display matplotlib to plot speedup"
52    return
53
54#
55#
56if __name__ ==  '__main__':
57  import sys
58  process()
59
60
61