Created
February 15, 2023 21:01
-
-
Save qazwsxal/36560f5e81253f00edfd811cb180e082 to your computer and use it in GitHub Desktop.
Plot graph of FS2 profiling information, includes 10th and 90th percentiles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
import sys | |
averageTime = 0.5 | |
NANOSECONDS_PER_SECOND = 1_000_000_000. | |
normalLabel = sys.argv[1] | |
changedLabel = sys.argv[2] | |
def FPScalc(time, frametime): | |
startIndex = 0 | |
currentTime = time[startIndex] | |
outTime = [] | |
outFPS = [] | |
ninety = [] | |
ten = [] | |
for i in range(startIndex + 1, len(time)): | |
for j in range(i, len(time)): | |
if (sum := np.sum(frametime[i:j]))>averageTime: | |
outTime.append(time[i]) | |
outFPS.append((j-i)/sum) | |
perc = np.percentile(frametime[i:j], (10,90)) | |
ten.append(1/perc[0]) | |
ninety.append(1/perc[1]) | |
break | |
return np.array(outTime), np.array(outFPS), np.array(ninety), np.array(ten) | |
def adjustData(data): | |
times = data[2:, 0] / NANOSECONDS_PER_SECOND | |
frametimes = data[2:, 1] / NANOSECONDS_PER_SECOND | |
times = times - times[0] | |
return FPScalc(times, frametimes) | |
normalData = np.genfromtxt(normalLabel, delimiter=';') | |
changedData = np.genfromtxt(changedLabel, delimiter=';') | |
nT, nF, n9, n1 = adjustData(normalData) | |
cT, cF, c9, c1 = adjustData(changedData) | |
plt.plot(nT, nF, label=normalLabel) | |
plt.fill_between(nT, n1, n9, alpha=0.2) | |
plt.plot(cT, cF, label=changedLabel) | |
plt.fill_between(cT, c1, c9, alpha=0.2) | |
plt.xlabel("Mission time") | |
plt.ylabel("FPS") | |
plt.legend(loc=1) | |
plt.savefig("image.png") | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment