OLD | NEW |
---|---|
1 (function(){ | 1 (function(){ |
2 | 2 |
3 // Populated from: http://www.medcalc.be/manual/t-distribution.php | 3 // Populated from: http://www.medcalc.be/manual/t-distribution.php |
4 // 95% confidence for N - 1 = 4 | 4 // 95% confidence for N - 1 = 4 |
5 var tDistribution = 2.776; | 5 var tDistribution = 2.776; |
6 | 6 |
7 // The number of individual test iterations to do | 7 // The number of individual test iterations to do |
8 var numTests = 5; | 8 var numTests = 5; |
9 | 9 |
10 // The type of run that we're doing (options are "runs/s" or "ms") | 10 // The type of run that we're doing (options are "runs/s" or "ms") |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
141 data.scale = num; | 141 data.scale = num; |
142 | 142 |
143 logTest(data); | 143 logTest(data); |
144 | 144 |
145 dequeue(); | 145 dequeue(); |
146 } | 146 } |
147 }, 1); | 147 }, 1); |
148 }); | 148 }); |
149 | 149 |
150 function compute(times, runs){ | 150 function compute(times, runs){ |
151 » » » var results = {runs: runs}, num = times.length; | 151 » » » var results = {runs: runs}, num = times.length, middle = num/2; |
152 | 152 |
153 times = times.sort(function(a,b){ | 153 times = times.sort(function(a,b){ |
154 return a - b; | 154 return a - b; |
155 }); | 155 }); |
156 | 156 |
157 // Make Sum | 157 // Make Sum |
158 results.sum = 0; | 158 results.sum = 0; |
159 | 159 |
160 for ( var i = 0; i < num; i++ ) | 160 for ( var i = 0; i < num; i++ ) |
161 results.sum += times[i]; | 161 results.sum += times[i]; |
162 | 162 |
163 // Make Min | 163 // Make Min |
164 results.min = times[0]; | 164 results.min = times[0]; |
165 | 165 |
166 // Make Max | 166 // Make Max |
167 results.max = times[ num - 1 ]; | 167 results.max = times[ num - 1 ]; |
168 | 168 |
169 // Make Mean | 169 // Make Mean |
170 results.mean = results.sum / num; | 170 results.mean = results.sum / num; |
171 | 171 |
172 // Make Median | 172 // Make Median |
173 results.median = num % 2 == 0 ? | 173 results.median = num % 2 == 0 ? |
174 » » » » (times[Math.floor(num/2)] + times[Math.ceil(num/ 2)]) / 2 : | 174 » » » » (times[middle-1] + times[middle]) / 2 : |
175 » » » » times[Math.round(num/2)]; | 175 » » » » times[Math.floor(middle)]; |
176 | 176 |
177 // Make Variance | 177 // Make Variance |
178 results.variance = 0; | 178 results.variance = 0; |
179 | 179 |
180 for ( var i = 0; i < num; i++ ) | 180 for ( var i = 0; i < num; i++ ) |
181 results.variance += Math.pow(times[i] - results. mean, 2); | 181 results.variance += Math.pow(times[i] - results. mean, 2); |
182 | 182 |
183 results.variance /= num - 1; | 183 results.variance /= num - 1; |
184 | 184 |
185 // Make Standard Deviation | 185 // Make Standard Deviation |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
223 var testDone = {}; | 223 var testDone = {}; |
224 var testNames = {}; | 224 var testNames = {}; |
225 var testVersions = {}; | 225 var testVersions = {}; |
226 var dataStore = []; | 226 var dataStore = []; |
227 var names = []; | 227 var names = []; |
228 var interval; | 228 var interval; |
229 var totalTime = 0; | 229 var totalTime = 0; |
230 var time = 0; | 230 var time = 0; |
231 var title, testName, testID, testSummary = {} , testSummaryNum = {}, max Total = 0, maxTotalNum = 0; | 231 var title, testName, testID, testSummary = {} , testSummaryNum = {}, max Total = 0, maxTotalNum = 0; |
232 var nameDone = {}; | 232 var nameDone = {}; |
233 var automated = false; | |
234 var post_json = false; | |
235 | 233 |
236 // Query String Parsing | 234 // Query String Parsing |
237 var search = window.limitSearch || (window.location.search || "?").subst r(1); | 235 var search = window.limitSearch || (window.location.search || "?").subst r(1); |
238 | 236 |
239 search = search.replace(/&runStyle=([^&]+)/, function(all, type){ | 237 search = search.replace(/&runStyle=([^&]+)/, function(all, type){ |
240 runStyle = type; | 238 runStyle = type; |
241 return ""; | 239 return ""; |
242 }); | 240 }); |
243 | 241 |
244 var parts = search.split("&"); | 242 var parts = search.split("&"); |
(...skipping 19 matching lines...) Expand all Loading... | |
264 var sharkMatch = new RegExp(m[1]); | 262 var sharkMatch = new RegExp(m[1]); |
265 doShark = function(name) { | 263 doShark = function(name) { |
266 return sharkMatch.test(name); | 264 return sharkMatch.test(name); |
267 }; | 265 }; |
268 } | 266 } |
269 } | 267 } |
270 | 268 |
271 m = /^numTests=(\d+)$/.exec(parts[i]); | 269 m = /^numTests=(\d+)$/.exec(parts[i]); |
272 if (m) | 270 if (m) |
273 numTests = Number(m[1]); | 271 numTests = Number(m[1]); |
274 | |
275 if (/^automated$/.exec(parts[i])) | |
276 automated = true; | |
277 if (/^post_json$/.exec(parts[i])) | |
278 post_json = true; | |
279 } | 272 } |
280 | 273 |
281 jQuery(function(){ | 274 jQuery(function(){ |
282 var id = search.match(/id=([\d,]+)/); | 275 var id = search.match(/id=([\d,]+)/); |
283 | 276 |
284 if ( none && !id ) { | 277 if ( none && !id ) { |
285 $("#overview").hide(); | 278 $("#overview").hide(); |
286 return; | 279 return; |
287 } | 280 } |
288 | 281 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
377 pre.style.display = "none"; | 370 pre.style.display = "none"; |
378 pre.innerHTML = "__start_report" + summa ry + "__end_report"; | 371 pre.innerHTML = "__start_report" + summa ry + "__end_report"; |
379 document.body.appendChild( pre ); | 372 document.body.appendChild( pre ); |
380 } | 373 } |
381 | 374 |
382 if ( typeof goQuitApplication !== "undefined" ) { | 375 if ( typeof goQuitApplication !== "undefined" ) { |
383 goQuitApplication(); | 376 goQuitApplication(); |
384 } | 377 } |
385 | 378 |
386 } else if ( dataStore && dataStore.length ) { | 379 } else if ( dataStore && dataStore.length ) { |
387 » » » » if (!automated) { | 380 » » » » $("body").addClass("alldone"); |
388 » » » » » $("body").addClass("alldone"); | 381 » » » » var div = jQuery("<div class='results'>Saving... </div>").insertBefore("#overview"); |
389 » » » » » var div = jQuery("<div class='results'>S aving...</div>").insertBefore("#overview"); | 382 » » » » jQuery.ajax({ |
390 » » » » » jQuery.ajax({ | 383 » » » » » type: "POST", |
391 » » » » » » type: "POST", | 384 » » » » » url: "store.php", |
392 » » » » » » url: "store.php", | 385 » » » » » data: "data=" + encodeURIComponent(JSON. stringify(dataStore)) + "&style=" + runStyle, |
393 » » » » » » data: "data=" + encodeURICompone nt(JSON.stringify(dataStore)) + "&style=" + runStyle, | 386 » » » » » success: function(id){ |
394 » » » » » » success: function(id){ | 387 » » » » » » var url = window.location.href.r eplace(/\?.*$/, "") + "?id=" + id; |
395 » » » » » » » var url = window.locatio n.href.replace(/\?.*$/, "") + "?id=" + id; | 388 » » » » » » div.html("Results saved. You can access them at a later time at the following URL:<br/><strong><a href='" + url + "'>" + url + "</a></strong></div>"); |
396 » » » » » » » div.html("Results saved. You can access them at a later time at the following URL:<br/><strong><a href=' " + url + "'>" + url + "</a></strong></div>"); | 389 » » » » » } |
397 » » » » » » } | 390 » » » » }); |
398 » » » » » }); | |
399 » » » » } else if (post_json) { | |
400 » » » » » jQuery.ajax({ | |
401 » » » » » » type: "POST", | |
402 » » » » » » url: "store.php", | |
403 » » » » » » data: "data=" + encodeURICompone nt(JSON.stringify(window.automation.GetResults())) | |
404 » » » » » }); | |
405 » » » » } | |
406 » » » » else { | |
407 » » » » » window.automation.SetDone(); | |
408 » » » » } | |
409 } | 391 } |
410 } | 392 } |
411 } | 393 } |
412 | 394 |
413 function updateTimebar(){ | 395 function updateTimebar(){ |
414 $("#timebar").html("<span><strong>" + (runStyle === "runs/s" ? M ath.pow(Math.E, maxTotal / maxTotalNum) : maxTotal).toFixed(2) + "</strong>" + r unStyle + " (Total)</span>"); | 396 $("#timebar").html("<span><strong>" + (runStyle === "runs/s" ? M ath.pow(Math.E, maxTotal / maxTotalNum) : maxTotal).toFixed(2) + "</strong>" + r unStyle + " (Total)</span>"); |
415 } | 397 } |
416 | 398 |
417 // Run once all the test files are fully loaded | 399 // Run once all the test files are fully loaded |
418 function init(){ | 400 function init(){ |
419 for ( var n = 0; n < names.length; n++ ) { | 401 for ( var n = 0; n < names.length; n++ ) { |
420 queue = queue.concat( queues[ names[n] ] ); | 402 queue = queue.concat( queues[ names[n] ] ); |
421 } | 403 } |
422 | 404 |
423 totalTime = time; | 405 totalTime = time; |
424 time += timePerTest; | 406 time += timePerTest; |
425 updateTime(); | 407 updateTime(); |
426 | 408 |
427 » » if (!automated) { | 409 » » $("#pause") |
428 » » » $("#pause") | 410 » » » .val("Run") |
429 » » » » .val("Run") | 411 » » » .click(function(){ |
430 » » » » .click(function(){ | 412 » » » » if ( interval ) { |
431 » » » » » if ( interval ) { | 413 » » » » » interval = null; |
432 » » » » » » interval = null; | 414 » » » » » this.value = "Run"; |
433 » » » » » » this.value = "Run"; | 415 » » » » } else { |
434 » » » » » } else { | 416 » » » » » if ( !interval ) { |
435 » » » » » » if ( !interval ) { | 417 » » » » » » interval = true; |
436 » » » » » » » interval = true; | 418 » » » » » » dequeue(); |
437 » » » » » » » dequeue(); | |
438 » » » » » » } | |
439 » » » » » » this.value = "Pause"; | |
440 } | 419 } |
441 » » » » }); | 420 » » » » » this.value = "Pause"; |
442 » » } else { | 421 » » » » } |
443 » » » $("#pause") | 422 » » » }); |
444 » » » » .val("Automated") | |
445 » » » » .click(function(){}); | |
446 » » » interval = true; | |
447 » » » dequeue(); | |
448 » » } | |
449 | 423 |
450 if ( window.limitSearch ) { | 424 if ( window.limitSearch ) { |
451 $("#pause").click(); | 425 $("#pause").click(); |
452 } | 426 } |
453 } | 427 } |
454 | 428 |
455 function initTest(curID){ | 429 function initTest(curID){ |
456 $("<div class='result-item'></div>") | 430 $("<div class='result-item'></div>") |
457 .append( testElems[ curID ] ) | 431 .append( testElems[ curID ] ) |
458 .append( "<p>" + (tests[curID] ? tests[ curID ].desc : " ") + "<br/><a href='" + | 432 .append( "<p>" + (tests[curID] ? tests[ curID ].desc : " ") + "<br/><a href='" + |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
797 testElems[testID] = $("<div class='test'></div>") | 771 testElems[testID] = $("<div class='test'></div>") |
798 .click(function(){ | 772 .click(function(){ |
799 var next = jQuery(this).next().next(); | 773 var next = jQuery(this).next().next(); |
800 if ( next.children().length == 0 ) return; | 774 if ( next.children().length == 0 ) return; |
801 var display = next.css("display"); | 775 var display = next.css("display"); |
802 next.css("display", display == 'none' ? 'block' : 'none'); | 776 next.css("display", display == 'none' ? 'block' : 'none'); |
803 }); | 777 }); |
804 | 778 |
805 updateTestPos({curID: testID, collection: tests[testID] ? tests[ testID].name : testID, version: testVersions[testID]}, true); | 779 updateTestPos({curID: testID, collection: tests[testID] ? tests[ testID].name : testID, version: testVersions[testID]}, true); |
806 } | 780 } |
807 | |
808 if (automated) { | |
809 // Add some more stuff if running in automated mode. | |
Nico
2016/11/14 22:20:58
we're not using this, yes?
dvallet
2016/11/15 02:19:38
Not really sure, it seems like it just adds some e
Nico
2016/11/15 15:30:06
The readme says "This benchmark was slightly modif
dvallet
2016/11/15 23:18:05
I'm fairly certain that the automation bit was add
| |
810 window.automation = {} | |
811 window.automation.SetDone = function() { | |
812 console.log("Total: " + this.GetScore()); | |
813 window.document.cookie = "__done=1; path=/"; | |
814 } | |
815 window.automation.GetScore = function() { | |
816 return (runStyle === "runs/s" ? Math.pow(Math.E, maxTota l / maxTotalNum) : maxTotal).toString(); | |
817 } | |
818 window.automation.GetResults = function() { | |
819 var results = {}; | |
820 var aggregated = {}; | |
821 function normalizeName(name) { | |
822 // At least for ui_tests, dots are not allowed. | |
823 return name.replace(".", "_"); | |
824 } | |
825 function appendToAggregated(name, value) { | |
826 name = normalizeName(name); | |
827 (aggregated[name] || (aggregated[name] = [])).pu sh(Math.log(value)); | |
828 } | |
829 | |
830 for (var i = 0; i < dataStore.length; i++) { | |
831 var data = dataStore[i]; | |
832 var topName = data.collection.split("-", 1)[0]; | |
833 appendToAggregated(topName, data.mean); | |
834 appendToAggregated(data.collection, data.mean); | |
835 results[normalizeName(data.collection + "/" + da ta.name)] = data.mean.toString(); | |
836 } | |
837 | |
838 for (var name in aggregated) { | |
839 var means = aggregated[name]; | |
840 var sum = 0; | |
841 for (var i = 0; i < means.length; i++) sum += me ans[i]; | |
842 results[name] = Math.pow(Math.E, sum/means.lengt h).toString(); | |
843 } | |
844 | |
845 return results; | |
846 } | |
847 } | |
848 })(); | 781 })(); |
OLD | NEW |