-
Notifications
You must be signed in to change notification settings - Fork 52
/
diff.js
50 lines (43 loc) · 1.2 KB
/
diff.js
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
'use strict';
var path = require('path'),
temp = require('temp'),
gm = require('gm'),
looksSame = require('..');
function imagePath(image) {
return path.resolve(__dirname, '..', 'test', 'data', 'src', image);
}
function benchamrkDiff(title, refImage, currImage) {
suite(title, function() {
var path1 = temp.path({suffix: '.png'}),
path2 = temp.path({suffix: '.png'});
set('iterations', 1000);
bench('looksSame', function(next) {
looksSame.createDiff({
reference: refImage,
current: currImage,
diff: path1,
highlightColor: '#ff00ff'
}, next);
});
bench('gm', function(next) {
gm.compare(
refImage,
currImage,
{
file: path2,
highlightStyle: 'assign',
highlightColor: '"#ff00ff"'
},
next
);
});
});
}
benchamrkDiff('small diff',
imagePath('ref.png'),
imagePath('different.png')
);
benchamrkDiff('large diff',
imagePath('large-ref.png'),
imagePath('large-different.png')
);