Created
November 14, 2018 13:27
-
-
Save netroy/fc6974e004a1b5e23dba11c0cd231616 to your computer and use it in GitHub Desktop.
Revisions
-
netroy created this gist
Nov 14, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ const sharp = require('sharp') const Jimp = require('jimp') const { Suite } = require('benchmark') var suite = new Suite() // add tests suite .add('Sharp', { defer: true, fn: deferred => { sharp('test.jpg') .resize({ width: 100 }) .jpeg({ quality: 60 }) // .toFile('1.jpg') .toBuffer() .then(() => { deferred.resolve() }) } }) .add('Jimp', { defer: true, fn: deferred => { Jimp.read('test.jpg') .then(lenna => lenna .resize(100, Jimp.AUTO) .quality(60) // .write('2.jpg') .getBufferAsync(Jimp.MIME_JPEG) ) .then(() => { deferred.resolve() }) } }) // add listeners .on('cycle', event => { console.log(String(event.target)) }) .on('complete', function () { console.log('Fastest is ' + this.filter('fastest').map('name')) }) // run async .run({ 'async': true }) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ Sharp x 219 ops/sec ±1.51% (80 runs sampled) Jimp x 1.50 ops/sec ±5.26% (12 runs sampled) Fastest is Sharp This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ Sharp x 215 ops/sec ±1.08% (80 runs sampled) Jimp x 1.45 ops/sec ±8.49% (11 runs sampled) Fastest is Sharp