forked from cztomczak/cefpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathperformance.html
More file actions
293 lines (247 loc) · 7.75 KB
/
performance.html
File metadata and controls
293 lines (247 loc) · 7.75 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
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
<!DOCTYPE HTML>
<html>
<head>
<title>Performance Tests</title>
<style>
body { font-family: Tahoma, Serif; font-size: 9pt; }
</style>
</head>
<body bgcolor="white">
<h1>Performance Tests</h1>
<input type="button" value="Run Tests" onClick="run();" id="run"/> Filter: <input type="text" size="50" id="filters"/>
<div><span id="statusBox"></span> <progress id="progressBox" value="0" style="display:none"></progress></div>
<div style="padding-top:10px; padding-bottom:10px">
<table id="resultTable" border="1" cellspacing="1" cellpadding="4">
<thead>
<tr>
<td>Name</td>
<td>Iterations per Run</td>
<td>Avg (ms)</td>
<td>Min (ms)</td>
<td>Max (ms)</td>
<td>StdDev (ms)</td>
<td>Runs (ms)</td>
</tr>
</thead>
<!-- result rows here -->
</table>
</div>
<hr width="80%">
Result 1: <input type="text" size="100" id="result1"/>
<br/>Result 2: <input type="text" size="100" id="result2"/>
<br/><input type="button" value="Compare" onClick="compare();" id="compare"/>
<div style="padding-top:10px; padding-bottom:10px">
<table id="compareTable" border="1" cellspacing="1" cellpadding="4">
<thead>
<tr>
<td>Name</td>
<td>Result 1 Avg (ms)</td>
<td>Result 2 Avg (ms)</td>
<td>% Diff</td>
</tr>
</thead>
<!-- result rows here -->
</table>
</div>
<script type="text/javascript">
function run() {
var runElement = document.getElementById("run");
var filtersElement = document.getElementById("filters");
var compareElement = document.getElementById("compare");
var result1Element = document.getElementById("result1");
var result2Element = document.getElementById("result2");
// Number of runs for each test.
var testRuns = 10;
// Delay between test runs.
var runDelay = 0;
// Retrieve the list of all tests.
var allTests = window.GetPerfTests();
// Populated with the list of tests that will be run.
var tests = [];
var currentTest = 0;
var testList = filtersElement.value.trim();
if (testList.length > 0) {
// Include or exclude specific tests.
var included = [];
var excluded = [];
var testNames = testList.split(",");
// Identify included and excluded tests.
for (i = 0; i < testNames.length; ++i) {
var testName = testNames[i].trim();
if (testName[0] == '-') {
// Exclude the test.
excluded.push(testName.substr(1));
} else {
// Include the test.
included.push(testName);
}
}
if (included.length > 0) {
// Only use the included tests.
for (i = 0; i < allTests.length; ++i) {
var test = allTests[i];
var testName = test[0];
if (included.indexOf(testName) >= 0)
tests.push(test);
}
} else if (excluded.length > 0) {
// Use all tests except the excluded tests.
for (i = 0; i < allTests.length; ++i) {
var test = allTests[i];
var testName = test[0];
if (excluded.indexOf(testName) < 0)
tests.push(test);
}
}
} else {
// Run all tests.
tests = allTests;
}
function updateStatusComplete() {
var statusBox = document.getElementById("statusBox");
statusBox.innerText = 'All tests completed.';
runElement.disabled = false;
filtersElement.disabled = false;
result1Element.disabled = false;
result2Element.disabled = false;
compareElement.disabled = false;
}
function updateStatus(test) {
var statusBox = document.getElementById("statusBox");
var progressBox = document.getElementById("progressBox");
if (test.run >= test.totalRuns) {
statusBox.innerText = test.name + " completed.";
progressBox.style.display = 'none';
} else {
statusBox.innerText = test.name + " (" + test.run + "/" + test.totalRuns + ")";
progressBox.value = (test.run / test.totalRuns);
progressBox.style.display = 'inline';
}
}
function appendResult(test) {
var e = document.getElementById("resultTable");
// Calculate the average.
var avg = test.total / test.totalRuns;
// Calculate the standard deviation.
var sqsum = 0;
for (i = 0; i < test.results.length; ++i) {
var diff = test.results[i] - avg;
sqsum += diff * diff;
}
var stddev = Math.round(Math.sqrt(sqsum / test.totalRuns) * 100.0) / 100.0;
e.insertAdjacentHTML("beforeEnd", [
"<tr>",
"<td>", test.name, "</td>",
"<td>", test.iterations, "</td>",
"<td>", avg, "</td>",
"<td>", test.min, "</td>",
"<td>", test.max, "</td>",
"<td>", stddev, "</td>",
"<td>", test.results.join(", "), "</td>",
"<tr>"
].join(""));
if (result1Element.value.length > 0)
result1Element.value += ",";
result1Element.value += test.name + "=" + avg;
}
// Execute the test function.
function execTestFunc(name) {
return window.RunPerfTest(name);
}
// Schedule the next test.
function nextTest(test) {
appendResult(test);
currentTest++;
runTest();
}
// Schedule the next step for the current test.
function nextTestStep(test) {
setTimeout(function () { execTest(test); }, runDelay);
}
// Perform the next step for the current test.
function execTest(test) {
updateStatus(test);
if (!test.warmedUp) {
execTestFunc(test.name);
test.warmedUp = true;
return nextTestStep(test);
}
if (test.run >= test.totalRuns)
return nextTest(test);
var elapsed = execTestFunc(test.name);
test.results.push(elapsed);
test.total += elapsed;
if (!test.min) test.min = elapsed;
else if (test.min > elapsed) test.min = elapsed;
if (!test.max) test.max = elapsed;
else if (test.max < elapsed) test.max = elapsed;
test.run++;
return nextTestStep(test);
}
function runTest() {
if (currentTest == tests.length) {
updateStatusComplete();
return;
}
var test = {
name: tests[currentTest][0],
iterations: tests[currentTest][1],
warmedUp: false,
total: 0,
totalRuns: testRuns,
run: 0,
results: []
};
setTimeout(function () { execTest(test); }, runDelay);
}
// Schedule the first test.
if (tests.length > 0) {
runElement.disabled = true;
filtersElement.disabled = true;
result1Element.value = "";
result1Element.disabled = true;
result2Element.disabled = true;
compareElement.disabled = true;
runTest();
}
}
function compare() {
var result1 = document.getElementById("result1").value.trim();
var result2 = document.getElementById("result2").value.trim();
if (result1.length == 0 || result2.length == 0)
return;
var r1values = result1.split(",");
var r2values = result2.split(",");
for (i = 0; i < r1values.length; ++i) {
var r1parts = r1values[i].split("=");
var r1name = r1parts[0].trim();
var r1val = r1parts[1].trim();
for (x = 0; x < r2values.length; ++x) {
var r2parts = r2values[x].split("=");
var r2name = r2parts[0].trim();
var r2val = r2parts[1].trim();
if (r2name == r1name) {
appendResult(r1name, r1val, r2val);
// Remove the matching index.
r2values.splice(x, 1);
break;
}
}
}
function appendResult(name, r1val, r2val) {
var e = document.getElementById("compareTable");
// Calculate the percent difference.
var diff = Math.round(((r2val - r1val) / r1val) * 10000.0) / 100.0;
e.insertAdjacentHTML("beforeEnd", [
"<tr>",
"<td>", name, "</td>",
"<td>", r1val, "</td>",
"<td>", r2val, "</td>",
"<td>", diff, "</td>",
"<tr>"
].join(""));
}
}
</script>
</body>
</html>