-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathperf.html
105 lines (100 loc) · 3.37 KB
/
perf.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
<!doctype html>
<!--
To re-use this page change <title>, github link
and the list of scripts at the end.
-->
<html lang="en">
<head>
<meta charset="utf-8">
<title>benchmarks for uglymol</title>
<style>
body { background-color: #ddd; font: 18px sans-serif; padding: 10px 20px; }
a { color: #22b; text-decoration: none; }
li.running a { background-color: orange; }
body.busy * { cursor: progress; }
code { display: inline-block; margin: auto; white-space:pre-wrap;
background-color: #bbb; font-size: 80%; padding: 10px; }
</style>
</head>
<body onload="onload();">
<p>Platform: <span id="platform">-</span></p>
<p>Benchmarks from
<a href="https://github.com/uglymol/uglymol/tree/master/perf/"
>uglymol/perf</a>. Click one and wait.
<ul id="list"></ul>
<script src="node_modules/lodash/lodash.min.js"></script>
<script src="node_modules/platform/platform.js"></script>
<script src="node_modules/benchmark/benchmark.js"></script>
<script>
function onload() {
document.getElementById('platform').innerHTML = Benchmark.platform;
};
var suites = [];
function output(html, style) {
var p = document.getElementById('tmp') || document.createElement('p');
p.removeAttribute('id');
p.innerHTML = html;
if (style === 'E') p.style.color = '#d00';
else if (style === 'TMP') p.id = 'tmp';
document.body.appendChild(p);
}
window.onerror = function (msg, url, lineNo) {
output(url + ':' + lineNo + ':\n' + msg, 'E')
return false;
};
var util = {
open_as_utf8: function(filename) {
var req = new XMLHttpRequest();
req.open('GET', 'data/' + filename, false);
req.send(null);
return req.response;
},
open_as_array_buffer: function (filename) {
var req = new XMLHttpRequest();
req.overrideMimeType('text\/plain; charset=x-user-defined');
req.open('GET', 'data/' + filename, false);
req.send(null);
var str = req.response;
var ab = new ArrayBuffer(str.length);
var view = new Uint8Array(ab);
for (var i = 0; i < str.length; ++i) {
view[i] = str.charCodeAt(i);
}
return ab;
},
bench: function (name, fn, options) {
var b = new Benchmark(name, fn, options);
b.on('complete', function (event) {
output(' ' + event.target);
});
b.on('error', function (event) {
output(b.error, 'E');
});
b.fn(); // run once, for possible side effects
var li = document.createElement('li');
li.innerHTML = '<a href="#">' + b.name + '</a>';
li.firstChild.onclick = function () {
if (document.body.classList.contains('busy')) return false;
document.body.classList.add('busy');
li.classList.add('running');
output(name + ' ...<br><code>' + fn + '</code>', 'TMP');
setTimeout(function () { // let the browser update styles
b.run(); // here the benchmark runs - it can take several seconds
document.body.classList.remove('busy');
li.classList.remove('running');
}, 100);
return false;
};
document.getElementById('list').appendChild(li);
return b;
}
};
</script>
<!-- uglymol scripts -->
<script src="uglymol.js"></script>
<script src="perf/model.js"></script>
<script src="perf/elmap.js"></script>
<script src="perf/isosurface.js"></script>
<script src="perf/viewer.js"></script>
</body>
</html>