xref: /petsc/src/benchmarks/streams/process.py (revision d3ae85c4231eeb9c96a2cdde9142a652e423115c)
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 plot speedup"
38    return
39
40  try:
41    import matplotlib.pyplot as plt
42
43    plt.title('Perfect and Streams Speedup')
44    plt.plot(hosts.keys(),hosts.keys(),'b-o',hosts.keys(),speedups.values(),'r-o')
45    plt.show()
46
47#
48#
49if __name__ ==  '__main__':
50  import sys
51  process()
52
53
54