1 | 'use strict';
|
2 | var path = require('path'),
|
3 | temp = require('temp'),
|
4 |
|
5 | gm = require('gm'),
|
6 | looksSame = require('..');
|
7 |
|
8 | function imagePath(image) {
|
9 | return path.resolve(__dirname, '..', 'test', 'data', 'src', image);
|
10 | }
|
11 |
|
12 | function benchmarkDiff(title, refImage, currImage) {
|
13 | suite(title, function() {
|
14 | var path1 = temp.path({suffix: '.png'}),
|
15 | path2 = temp.path({suffix: '.png'});
|
16 |
|
17 | set('iterations', 1000);
|
18 | bench('looksSame', function(next) {
|
19 | looksSame.createDiff({
|
20 | reference: refImage,
|
21 | current: currImage,
|
22 | diff: path1,
|
23 | highlightColor: '#ff00ff'
|
24 | }, next);
|
25 | });
|
26 |
|
27 | bench('gm', function(next) {
|
28 | gm.compare(
|
29 | refImage,
|
30 | currImage,
|
31 | {
|
32 | file: path2,
|
33 | highlightStyle: 'assign',
|
34 | highlightColor: '"#ff00ff"'
|
35 | },
|
36 | next
|
37 | );
|
38 | });
|
39 | });
|
40 | }
|
41 |
|
42 | benchmarkDiff('small diff',
|
43 | imagePath('ref.png'),
|
44 | imagePath('different.png')
|
45 | );
|
46 |
|
47 | benchmarkDiff('large diff',
|
48 | imagePath('large-ref.png'),
|
49 | imagePath('large-different.png')
|
50 | );
|