-
Notifications
You must be signed in to change notification settings - Fork 0
/
benchmark.html
48 lines (43 loc) · 1.23 KB
/
benchmark.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WebGL - 2D Image</title>
</head>
<body>
<script src="/dist/hermite-resize-webgl.js"></script>
<script src="/src/hermite-resize-js.js"></script>
<script src="/bower/lodash/lodash.min.js"></script>
<script src="/bower/benchmark/benchmark.js"></script>
<script>
var options = {
width: 400,
height: 300
};
var glScale = GLScale(options);
var canvas = document.createElement('canvas');
var context = canvas.getContext('2d');
GLScale.loadImage('/test/img/flower.jpg', function (err, image) {
var suite = new Benchmark.Suite;
suite.add('GLScale', function() {
glScale(image);
})
.add('Hermite Resize', function() {
var W = image.width;
var H = image.height;
canvas.width = W;
canvas.height = H;
context.drawImage(image, 0, 0);
resample_hermite(canvas, W, H, options.width, options.height);
})
.on('cycle', function(event) {
console.log(String(event.target));
})
.on('complete', function() {
console.log('Fastest is ' + this.filter('fastest').map('name'));
})
.run({ 'async': true });
});
</script>
</body>
</html>