-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
226 lines (177 loc) · 6.01 KB
/
index.html
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>tosu timings graphs</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@500&display=swap');
body {
font-family: 'Montserrat', sans-serif;
}
.block {
font-family: 'Montserrat', sans-serif;
text-align: center;
}
.avg {
margin-bottom: 3em;
display: flex;
justify-content: center;
align-items: center;
flex-wrap: wrap;
gap: 1em;
}
.avg>div::before {
content: '';
width: 1em;
height: 1em;
display: block;
background: var(--color);
border-radius: 1em;
}
.avg>div {
justify-content: center;
align-items: center;
display: flex;
gap: 0.5em;
white-space: nowrap;
}
h1 {
text-align: center;
}
select {
margin: 0 auto;
padding: 0.6em 1.7em;
font-size: 20px;
font-weight: 700;
font-family: 'Montserrat', sans-serif;
display: block;
}
</style>
</head>
<body>
<script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
<script>
let selected = '';
let chart = '';
const colors = [
'#FF004F',
'#FF7F50',
'#954535',
'#FCF75E',
'#90EE90',
'#00CCCC',
'#0070FF',
'#8F00FF',
'#E52B50',
'#FFFAFA',
'#C0C0C0',
'#242124',
]
const graph_options = {
chart: {
width: window.innerWidth - 100, height: 250, type: 'area',
animations: {
enabled: false,
easing: 'easeinout',
speed: 800,
animateGradually: {
enabled: true,
delay: 150
},
dynamicAnimation: {
enabled: true,
speed: 350
}
}
},
colors,
dataLabels: { enabled: false },
stroke: { curve: 'smooth' },
tooltip: {
x: {
formatter: function (value) {
return new Date(value)
.toISOString()
.split('T')[1]
.replace('Z', '')
}
},
},
series: [],
xaxis: {
type: "numeric",
categories: [],
labels: {
formatter: function (value, timestamp) {
return new Date(value).toISOString() // The formatter function overrides format property
}
}
},
}
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
const files = ['cpp', 'rust'];
async function main(params) {
for (let i = 0; i < files.length; i++) {
const file = files[i];
const request = await fetch(`/${file}.json`);
const text = await request.text();
window[`stats-${file}`] = JSON.parse(text);
buildUI(file);
buildGraph(file);
};
};
function buildUI(file) {
const select = document.createElement("select");
select.id = `sl-${file}`;
const options = Object.keys(window[`stats-${file}`]);
options.forEach((optionText) => {
const option = document.createElement("option");
option.text = optionText;
select.add(option);
});
select.addEventListener("change", () => {
selected = select.value;
// buildGraph(select.id.replace('sl-', ''));
files.forEach(r => {
buildGraph(r);
document.getElementById(`sl-${r}`).value = selected;
});
});
const div = document.createElement('div');
div.classList.add('block');
div.innerHTML = `<div id="${file}"></div>`;
const title = document.createElement('h1');
title.innerHTML = file;
const average = document.createElement('div');
average.id = `avg-${file}`;
average.classList.add('avg');
document.body.append(title);
document.body.appendChild(select);
document.body.append(div);
document.body.append(average);
window[file] = new ApexCharts(document.querySelector(`#${file}`), graph_options)
window[file].render();
};
function buildGraph(file) {
const keys = Object.keys(window[`stats-${file}`]);
const key = selected || keys[0];
const data = window[`stats-${file}`][key];
if (data == null) return;
const options = JSON.parse(JSON.stringify(graph_options))
graph_options.series = data.series;
graph_options.xaxis.categories = data.xaxis.categories;
const average = document.getElementById(`avg-${file}`);
average.innerHTML = '';
Object.keys(data.average).forEach((r, index) => {
const div = document.createElement('div');
div.innerHTML = `${r}: ${data.average[r].toFixed(3)}`;
div.style.setProperty('--color', colors[index])
average.appendChild(div);
});
window[file].updateOptions(graph_options);
};
main()
</script>
</body>
</html>