-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbrowsers.html
77 lines (47 loc) · 1.18 KB
/
browsers.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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta charset="UTF-8" />
<title>Benchmark</title>
<style media="screen" type="text/css">
body {
font-family: monospace;
}
</style>
<script type="text/javascript">
function benchmark1 () {
const t0 = performance.now();
x = 1
for (i=0; i<99999999; i++) {
x = (i+i+2*i+1-0.379)/(x);
}
//console.log(x);
const t1 = performance.now();
//console.log(`command took ${(t1 - t0)/1000}s.`);
var elapsed = (t1 - t0)/1000
document.getElementById('result1').innerHTML = `command took ${elapsed}s`;
}
function benchmark2 () {
const t0 = performance.now();
var x = 0;
for (i=0; i<100000000; i++) {
x += Math.floor(Math.random() * 100);
}
//console.log(x);
const t1 = performance.now();
//console.log(`command took ${(t1 - t0)/1000}s.`);
var elapsed = (t1 - t0)/1000
document.getElementById('result1').innerHTML = `command took ${elapsed}s`;
}
window.onload = function () {
benchmark2();
}
</script>
</head>
<body>
<h1>
<div id="result1">Calculating ...</div>
</h1>
</body>
</html>