Skip to content

Commit

Permalink
WIP: add imageflow to performance benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
lovell committed Sep 5, 2022
1 parent c1393da commit 0467494
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/bench/package.json
Expand Up @@ -8,6 +8,7 @@
"test": "node perf && node random && node parallel"
},
"devDependencies": {
"@imazen/imageflow": "0.0.1-rc17",
"@squoosh/cli": "0.7.2",
"@squoosh/lib": "0.4.0",
"async": "3.2.4",
Expand Down
38 changes: 38 additions & 0 deletions test/bench/perf.js
Expand Up @@ -15,6 +15,7 @@ const imagemagick = require('imagemagick');
const mapnik = require('mapnik');
const jimp = require('jimp');
const squoosh = require('@squoosh/lib');
const imageflow = require('@imazen/imageflow');

const fixtures = require('../fixtures');

Expand Down Expand Up @@ -253,6 +254,43 @@ async.series({
});
}
});
// imageflow
jpegSuite.add('imageflow-file-file', {
defer: true,
fn: function (deferred) {
new imageflow.Steps(new imageflow.FromFile(fixtures.inputJpg))
.constrainWithin(width, height, { down_filter: 'lanczos' })
.encode(
new imageflow.FromFile(outputJpg),
new imageflow.MozJPEG(80, false)
)
.execute()
.then(function () {
deferred.resolve();
})
.catch(function (err) {
throw err;
});
}
}).add('imageflow-buffer-buffer', {
defer: true,
fn: function (deferred) {
new imageflow.Steps(new imageflow.FromBuffer(inputJpgBuffer))
.constrainWithin(width, height, { down_filter: 'lanczos' })
.encode(
new imageflow.FromBuffer(null, 'key'),
new imageflow.MozJPEG(80, false)
)
.execute()
.then(function (buffer) {
assert.notStrictEqual(null, buffer);
deferred.resolve();
})
.catch(function (err) {
throw err;
});
}
});
// sharp
jpegSuite.add('sharp-buffer-file', {
defer: true,
Expand Down

0 comments on commit 0467494

Please sign in to comment.