mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 09:12:52 +00:00
68 lines
2.0 KiB
HTML
68 lines
2.0 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Rounded coordinates</title>
|
|
<style>
|
|
#mover {
|
|
width:10px;
|
|
height:10px;
|
|
background:black;
|
|
}
|
|
#moved {
|
|
width:5px;
|
|
height:5px;
|
|
background:red;
|
|
}
|
|
pre {
|
|
position:absolute;
|
|
top:120px;
|
|
width:500px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div id='mover'>
|
|
<div id='moved'></div>
|
|
</div>
|
|
<pre id='report'></pre>
|
|
<script src="benchmark.js"></script>
|
|
<script>
|
|
var suite = new Benchmark.Suite;
|
|
// add tests
|
|
suite
|
|
.add('translate', function() {
|
|
document.getElementById('mover').style.MozTransform = 'translate(' +
|
|
~~(Math.random() * 100) + 'px,' + ~~(Math.random() * 100) + 'px)';
|
|
})
|
|
.add('translate3d', function() {
|
|
document.getElementById('mover').style.MozTransform = 'translate3d(' +
|
|
~~((Math.random() * 100)) + 'px,' + ~~((Math.random() * 100)) + 'px, 0px)';
|
|
})
|
|
.add('matrix3d', function() {
|
|
document.getElementById('mover').style.MozTransform = 'matrix3d(' +
|
|
[1,0,0,0,
|
|
0,1,0,0,
|
|
0,0,1,0,
|
|
~~(Math.random() * 100),
|
|
~~(Math.random() * 100),0,1].join(',') + ')';
|
|
})
|
|
.add('matrix3d-string', function() {
|
|
document.getElementById('mover').style.MozTransform = 'matrix3d(' +
|
|
'1,0,0,0,0,1,0,0,0,0,1,0,' +
|
|
(~~(Math.random() * 100)) + ',' +
|
|
(~~(Math.random() * 100)) + ',0,1)';
|
|
})
|
|
// add listeners
|
|
.on('cycle', function(event) {
|
|
document.getElementById('report').innerHTML +=
|
|
String(event.target) + '\n';
|
|
})
|
|
.on('complete', function() {
|
|
document.getElementById('report').innerHTML +=
|
|
'Fastest is ' + this.filter('fastest').pluck('name') + '\n';
|
|
})
|
|
// run async
|
|
.run({ 'async': true });
|
|
</script>
|
|
</body>
|