Last active
August 29, 2015 14:10
-
-
Save ashildebrandt/111dc63dfa53239d285d to your computer and use it in GitHub Desktop.
Render Time (roughly graphs the render time of an image sequence)
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
""" | |
ash_rendertime.py | |
by [email protected] | |
Graphs the render time of an image sequence | |
Prerequisities: | |
matplotlib | |
Usage: | |
python rendertime.py | |
""" | |
from os import listdir | |
import os.path, time, sys, Tkinter, tkFileDialog | |
import matplotlib.pyplot as plt | |
def highestValue(input_list): | |
highest_value = 0 | |
for i in input_list: | |
if i > highest_value: | |
highest_value = i | |
return highest_value | |
def average(input_list, search): | |
output_list = [] | |
i = 0 | |
while i <= len(input_list): | |
tally = 0 | |
count = 0 | |
j = -(int(search/2)) | |
while j <= (int(search/2)): | |
try: | |
tally += input_list[i+j] | |
count += 1 | |
except: pass | |
j += 1 | |
output_list.append(tally/count) | |
i += 1 | |
return output_list | |
def main(): | |
# Get directory | |
root = Tkinter.Tk() | |
root.withdraw() | |
image_path = tkFileDialog.askdirectory(parent=root, title='Select image sequence directory') | |
root.destroy() | |
onlyfiles = [ f for f in listdir(image_path) if os.path.isfile(os.path.join(image_path,f)) ] | |
# Get time differences | |
plotter = [] | |
i = 0 | |
previous_time = os.path.getmtime(image_path+'/'+onlyfiles[0]) | |
sequence_length = len(onlyfiles) | |
onlyfiles.sort() | |
for i in onlyfiles[1:]: | |
difference = os.path.getmtime(image_path+'/'+i) - previous_time | |
plotter.append(difference) | |
previous_time = os.path.getmtime(image_path+'/'+i) | |
# Average the result to get a more accurate graph when rendering across multiple machines | |
plotter = average(plotter, 20) | |
# Plot result | |
plt.plot(plotter) | |
plt.ylabel('Render time (seconds)') | |
plt.xlabel('Frame') | |
plt.title('Render time') | |
plt.ylim([0,highestValue(plotter)]) | |
plt.xlim([0,sequence_length]) | |
plt.show() | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment