Commit c1513d04 authored by Daniel Brown's avatar Daniel Brown
Browse files

Added function to plot summed performance data

parent 5d15437e
......@@ -6,4 +6,4 @@ m m2 0.5 0.5 0 n4 dump
pd PD1 n2
xaxis m1 phi lin 0 360 360
xaxis m1 phi lin 0 360 10000
......@@ -2,18 +2,17 @@ import sys
sys.path.append("../")
from pykat import finesse
import pykat.profiling
import numpy as np
import pylab as pl
kat = finesse.kat()
kat.load("parse.kat")
#kat.load("D:\\finesse\\test\\kat_test\\physics\\mirror_astig_tilt_all_BH.kat")
kat.load('parse.kat')
kat.getPerformanceData = True
run = kat.run(printout=0,printerr=0)
[run, perfdata] = kat.run(printout=0,printerr=0)
pl.figure()
pykat.profiling.plotReducedPerformanceData(perfdata)
pl.plot(run.x,run.y)
pl.xlabel(run.xlabel)
pl.legend(run.ylabels)
pl.show()
......@@ -89,6 +89,7 @@ class kat(object):
self.__phase = None
self.__maxtem = None
self.__noxaxis = None
self.__time_code = None
@property
def maxtem(self): return self.__maxtem
......@@ -100,6 +101,11 @@ class kat(object):
@phase.setter
def phase(self,value): self.__phase = int(value)
@property
def getPerformanceData(self): return self.__time_code
@getPerformanceData.setter
def getPerformanceData(self,value): self.__time_code = bool(value)
@property
def noxaxis(self): return self.__noxaxis
@noxaxis.setter
......@@ -147,7 +153,12 @@ class kat(object):
katfile.writelines(r.katScript)
katfile.flush()
kat_exec = "{0} {1}".format(kat_exec, katfile.name)
flags = ""
if self.__time_code:
flags = flags + " --perf-timing "
kat_exec = "{0} {1} {2}".format(kat_exec, flags, katfile.name)
p=subprocess.Popen(kat_exec,
stdout=subprocess.PIPE,
......@@ -180,7 +191,6 @@ class kat(object):
r.ylabels = hdr[1:]
if save_output:
newoutfile = "{0}.out".format(base)
cwd = os.path.os.getcwd()
......@@ -209,8 +219,18 @@ class kat(object):
katfile.close()
perfData = []
return r
if self.__time_code:
perffile = open(root[0] + ".perf",'r')
for l in perffile.readlines():
vals = l.strip().split(' ')
perfData.append((vals[0], float(vals[1]), float(vals[2]), float(vals[3])))
return [r, perfData]
else:
return r
def add(self, obj) :
......
import numpy as np
import pylab as pl
def plotReducedPerformanceData(perfdata, ordered=False):
labels = []
times = []
for pd in perfdata:
if pd[0] in labels:
times[labels.index(pd[0])] += pd[3]
else:
labels.append(pd[0])
times.append(pd[3])
if ordered:
times,labels = (list(t) for t in zip(*sorted(zip(times,labels))))
ind = np.arange(len(labels))
fig = pl.figure()
plt = fig.add_subplot(111)
plt.barh(ind, times, height=0.5, log=True, align='center')
pl.yticks(ind, labels)
pl.show()
return labels, times
\ No newline at end of file
......@@ -9,7 +9,7 @@ from distutils.core import setup
setup(
name='PyKat',
version='0.0.1',
version='0.0.2',
author='Daniel Brown',
author_email='ddb@star.sr.bham.ac.uk',
packages=['pykat','pykat.gui','pykat.gui.resources'],
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment