Skip to content

Instantly share code, notes, and snippets.

@asarium
Created December 23, 2015 21:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asarium/2ce04d7d2ac01b40e66a to your computer and use it in GitHub Desktop.
Save asarium/2ce04d7d2ac01b40e66a to your computer and use it in GitHub Desktop.
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