-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathChartGenerator.py
More file actions
135 lines (126 loc) · 3.95 KB
/
ChartGenerator.py
File metadata and controls
135 lines (126 loc) · 3.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import plotly.graph_objects as go
import pandas as pd
import numpy as np
import math
import os
# chart parameters
csvfile = 'Frametime-Full' # source CSV file
outputDir = 'Frametime-OUTPUT' # destination graph file's directory
dataTitle = "Frametime (ms)" # main axis name
boxAndWhiskers = False # whether to render b&w or bar chart
def Result(renderer, mode, pCount, rWidth, rHeight, pComplexity, pDensity, pSpread):
# Return None if we should skip this column; otherwise return the name of the column.
#if renderer != "VBuffer":
# return None
if mode != "VertVert":
return None
if pCount != 1048576:
return None
if rWidth != 1024:
return None
if rHeight != 768:
return None
if pComplexity != 2:
return None
if pDensity != 400:
return None
#if pSpread != 29:
# return None
return renderer + ", " + str(float(pSpread if pSpread != 29 else 30)*0.001)
def getColour(renderer, mode, pCount, rWidth, rHeight, pComplexity, pDensity, pSpread):
# Returns the colour to use for a certain Series.
hue = 0
sat = 73 if boxAndWhiskers else 40
val = 50
# assign hue depending on renderer
if renderer == "Forward":
hue = 0
elif renderer == "GBuffer3":
hue = 90
elif renderer == "GBuffer6":
hue = 180
else:
hue = 270
# assign value depending on current variable for test
#if mode == "CompComp":
# val = 65
#elif mode == "GeomGeom":
# val = 55
#elif mode == "VertVert":
# val = 45
#else:
# val = 35
# assign value depending on density
if pSpread == 3:
val = 65
elif pComplexity == 29:
val = 50
elif pComplexity == 300:
val = 35
# return colour as HSV
return "hsl("+str(hue)+","+str(sat)+"%,"+str(val)+"%)"
def Settings(): # the string returned by this function will be written to a text file ".settings" in the destination folder.
str = outputDir + "\n\n"
#str += "Renderer: VBuffer\n"
str += "Mode: VertVert\n"
str += "ParticleCount: 1048576\n"
str += "ResolutionWidth: 1024\n"
str += "ResolutionHeight: 768\n"
str += "ParticleComplexity: 2\n"
str += "ParticleDensity: 400\n"
#str += "ParticleSpread: 29\n"
return str
firstCol = 4 # index in the CSV file of the first data column
gpu = None
renderer = None
mode = None
# Create an empty chart
fig = go.Figure()
# Function to create a directory if it doesn't exist
def mkdir(path):
try:
os.mkdir(path)
except OSError:
return
# Update the charts, save as HTML file, and show it in the default browser.
def ShowResults():
global fig, gpu
fig.update_layout(title=gpu, yaxis_title=dataTitle, plot_bgcolor='hsl(180,20%,98%)')
if not os.path.isfile('graphs/'):
mkdir('graphs/')
if not os.path.isfile('graphs/'+outputDir+'/'):
mkdir('graphs/'+outputDir+'/')
fig.write_html('graphs/' + outputDir + '/' + gpu + ".html", auto_open=True)
fig = go.Figure()
# Iterate over each column, reading the data.
df = pd.read_csv("src/" + csvfile + ".csv")
col = 0
for(columnName, columnData) in df.iteritems():
if col >= firstCol and col < len(df.columns)-1: # ignore initial Settings columns and very last column
if columnName[0:7] != "Unnamed":
if gpu != None: # output current data
ShowResults()
gpu = columnName
if type(columnData[0]) == type("str"):
renderer = columnData[0]
if type(columnData[1]) == type("str"):
mode = columnData[1]
pCount = int(columnData[2])
rWidth = int(columnData[3])
rHeight = int(columnData[4])
pComplexity = int(columnData[5])
pDensity = int(columnData[6])
pSpread = int(columnData[7])
avg = columnData[9]
name = Result(renderer, mode, pCount, rWidth, rHeight, pComplexity, pDensity, pSpread)
colour = getColour(renderer, mode, pCount, rWidth, rHeight, pComplexity, pDensity, pSpread)
if name != None:
if boxAndWhiskers:
fig.add_trace(go.Box(y=columnData[17:columnData.size-1], name=name, line=dict(color=colour)))
else:
fig.add_trace(go.Bar(x=[name], y=[avg], name=name, marker=dict(color=colour)))
col+=1
ShowResults()
settingsFile = open("graphs/" + outputDir + "/.settings.txt", "w")
settingsFile.write(Settings())
settingsFile.close()