Skip to content

Instantly share code, notes, and snippets.

@asarium asarium/graph.py
Created Dec 23, 2015

Embed
What would you like to do?
import numpy as np
import pylab as plot
import sys
averageTime = 0.5
MICROSECONDS_PER_SECOND = 1000000.
normalLabel = sys.argv[1]
changedLabel = sys.argv[2]
def average(time, frametime):
startIndex = 0
currentTime = time[startIndex]
outTime = []
outFPS = []
for i in range(startIndex + 1, len(time)):
if time[i] - currentTime >= averageTime:
val = np.mean(frametime[startIndex:i])
outTime.append(time[startIndex])
outFPS.append(val)
startIndex = i
currentTime = time[i]
return outTime, outFPS
def adjustData(data):
times = data[2:, 0] / MICROSECONDS_PER_SECOND
frametimes = data[2:, 1] / MICROSECONDS_PER_SECOND
times = times - times[0]
frametimes = 1 / frametimes
return average(times, frametimes)
normalData = np.genfromtxt("normal.csv", delimiter=';')
changedData = np.genfromtxt("changed.csv", delimiter=';')
nT, nF = adjustData(normalData)
cT, cF = adjustData(changedData)
plot.plot(nT, nF, label=normalLabel)
plot.plot(cT, cF, label=changedLabel)
plot.xlabel("Mission time")
plot.ylabel("FPS")
plot.legend(loc=1)
plot.savefig("image.png")
#plot.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.