mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 10:30:15 +02:00
Test: update perf test dependencies to latest
Drop squoosh as it does not support Node.js 20+
This commit is contained in:
parent
9d40a64120
commit
3c177af594
@ -1,14 +1,13 @@
|
|||||||
FROM ubuntu:23.10
|
FROM ubuntu:24.10
|
||||||
ARG BRANCH=main
|
ARG BRANCH=main
|
||||||
|
|
||||||
# Install basic dependencies
|
# Install basic dependencies
|
||||||
RUN apt-get -y update && apt-get install -y build-essential curl git ca-certificates gnupg
|
RUN apt-get -y update && apt-get install -y build-essential curl git ca-certificates gnupg
|
||||||
|
|
||||||
# Install latest Node.js LTS
|
# Install latest Node.js LTS
|
||||||
RUN mkdir -p /etc/apt/keyrings
|
RUN curl -fsSL https://deb.nodesource.com/setup_22.x -o nodesource_setup.sh
|
||||||
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
|
RUN bash nodesource_setup.sh
|
||||||
RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
|
RUN apt-get install -y nodejs
|
||||||
RUN apt-get -y update && apt-get install -y nodejs
|
|
||||||
|
|
||||||
# Install benchmark dependencies
|
# Install benchmark dependencies
|
||||||
RUN apt-get install -y imagemagick libmagick++-dev graphicsmagick
|
RUN apt-get install -y imagemagick libmagick++-dev graphicsmagick
|
||||||
@ -26,8 +25,4 @@ RUN node -v
|
|||||||
|
|
||||||
WORKDIR /tmp/sharp/test/bench
|
WORKDIR /tmp/sharp/test/bench
|
||||||
|
|
||||||
# Workaround for: https://github.com/emscripten-core/emscripten/pull/16917
|
|
||||||
# This could be removed once Squoosh is an optional dependency.
|
|
||||||
ENV NODE_OPTIONS="--no-experimental-fetch"
|
|
||||||
|
|
||||||
CMD [ "node", "perf" ]
|
CMD [ "node", "perf" ]
|
||||||
|
@ -8,16 +8,14 @@
|
|||||||
"test": "node perf && node random && node parallel"
|
"test": "node perf && node random && node parallel"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@squoosh/cli": "0.7.3",
|
"async": "3.2.6",
|
||||||
"@squoosh/lib": "0.5.3",
|
|
||||||
"async": "3.2.5",
|
|
||||||
"benchmark": "2.1.4",
|
"benchmark": "2.1.4",
|
||||||
"gm": "1.25.0",
|
"gm": "1.25.1",
|
||||||
"imagemagick": "0.1.3",
|
"imagemagick": "0.1.3",
|
||||||
"jimp": "0.22.10"
|
"jimp": "1.6.0"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@tensorflow/tfjs-node": "4.13.0",
|
"@tensorflow/tfjs-node": "4.22.0",
|
||||||
"mapnik": "4.5.9"
|
"mapnik": "4.5.9"
|
||||||
},
|
},
|
||||||
"license": "Apache-2.0"
|
"license": "Apache-2.0"
|
||||||
|
@ -3,9 +3,8 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const os = require('os');
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const { exec, execSync } = require('child_process');
|
const { execSync } = require('child_process');
|
||||||
|
|
||||||
const async = require('async');
|
const async = require('async');
|
||||||
const Benchmark = require('benchmark');
|
const Benchmark = require('benchmark');
|
||||||
@ -22,8 +21,8 @@ const sharp = require('../../');
|
|||||||
const gm = require('gm');
|
const gm = require('gm');
|
||||||
const imagemagick = require('imagemagick');
|
const imagemagick = require('imagemagick');
|
||||||
const mapnik = safeRequire('mapnik');
|
const mapnik = safeRequire('mapnik');
|
||||||
const jimp = require('jimp');
|
const { Jimp, JimpMime } = require('jimp');
|
||||||
const squoosh = require('@squoosh/lib');
|
|
||||||
process.env.TF_CPP_MIN_LOG_LEVEL = 1;
|
process.env.TF_CPP_MIN_LOG_LEVEL = 1;
|
||||||
const tfjs = safeRequire('@tensorflow/tfjs-node');
|
const tfjs = safeRequire('@tensorflow/tfjs-node');
|
||||||
|
|
||||||
@ -52,102 +51,21 @@ async.series({
|
|||||||
// jimp
|
// jimp
|
||||||
jpegSuite.add('jimp-buffer-buffer', {
|
jpegSuite.add('jimp-buffer-buffer', {
|
||||||
defer: true,
|
defer: true,
|
||||||
fn: function (deferred) {
|
fn: async function (deferred) {
|
||||||
jimp.read(inputJpgBuffer, function (err, image) {
|
const image = await Jimp.read(inputJpgBuffer)
|
||||||
if (err) {
|
await image
|
||||||
throw err;
|
.resize({ w: width, h: height, mode: Jimp.RESIZE_BICUBIC })
|
||||||
} else {
|
.getBuffer(JimpMime.jpeg, { quality: 80 });
|
||||||
image
|
deferred.resolve();
|
||||||
.resize(width, height, jimp.RESIZE_BICUBIC)
|
|
||||||
.quality(80)
|
|
||||||
.getBuffer(jimp.MIME_JPEG, function (err) {
|
|
||||||
if (err) {
|
|
||||||
throw err;
|
|
||||||
} else {
|
|
||||||
deferred.resolve();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}).add('jimp-file-file', {
|
}).add('jimp-file-file', {
|
||||||
defer: true,
|
defer: true,
|
||||||
fn: function (deferred) {
|
fn: async function (deferred) {
|
||||||
jimp.read(fixtures.inputJpg, function (err, image) {
|
const image = await Jimp.read(fixtures.inputJpg);
|
||||||
if (err) {
|
await image
|
||||||
throw err;
|
.resize({ w: width, h: height, mode: Jimp.RESIZE_BICUBIC })
|
||||||
} else {
|
.getBuffer(JimpMime.jpeg, { quality: 80 });
|
||||||
image
|
deferred.resolve();
|
||||||
.resize(width, height, jimp.RESIZE_BICUBIC)
|
|
||||||
.quality(80)
|
|
||||||
.write(outputJpg, function (err) {
|
|
||||||
if (err) {
|
|
||||||
throw err;
|
|
||||||
} else {
|
|
||||||
deferred.resolve();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// squoosh-cli
|
|
||||||
jpegSuite.add('squoosh-cli-file-file', {
|
|
||||||
defer: true,
|
|
||||||
fn: function (deferred) {
|
|
||||||
exec(`./node_modules/.bin/squoosh-cli \
|
|
||||||
--output-dir ${os.tmpdir()} \
|
|
||||||
--resize '{"enabled":true,"width":${width},"height":${height},"method":"lanczos3","premultiply":false,"linearRGB":false}' \
|
|
||||||
--mozjpeg '{"quality":80,"progressive":false,"optimize_coding":true,"quant_table":0,"trellis_multipass":false,"chroma_subsample":2,"separate_chroma_quality":false}' \
|
|
||||||
"${fixtures.inputJpg}"`, function (err) {
|
|
||||||
if (err) {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
deferred.resolve();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// squoosh-lib (GPLv3)
|
|
||||||
jpegSuite.add('squoosh-lib-buffer-buffer', {
|
|
||||||
defer: true,
|
|
||||||
fn: function (deferred) {
|
|
||||||
const pool = new squoosh.ImagePool(os.cpus().length);
|
|
||||||
const image = pool.ingestImage(inputJpgBuffer);
|
|
||||||
image.decoded
|
|
||||||
.then(function () {
|
|
||||||
return image.preprocess({
|
|
||||||
resize: {
|
|
||||||
enabled: true,
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
method: 'lanczos3',
|
|
||||||
premultiply: false,
|
|
||||||
linearRGB: false
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.then(function () {
|
|
||||||
return image.encode({
|
|
||||||
mozjpeg: {
|
|
||||||
quality: 80,
|
|
||||||
progressive: false,
|
|
||||||
optimize_coding: true,
|
|
||||||
quant_table: 0,
|
|
||||||
trellis_multipass: false,
|
|
||||||
chroma_subsample: 2,
|
|
||||||
separate_chroma_quality: false
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.then(function () {
|
|
||||||
return pool.close();
|
|
||||||
})
|
|
||||||
.then(function () {
|
|
||||||
return image.encodedWith.mozjpeg;
|
|
||||||
})
|
|
||||||
.then(function () {
|
|
||||||
deferred.resolve();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// mapnik
|
// mapnik
|
||||||
@ -648,98 +566,21 @@ async.series({
|
|||||||
// jimp
|
// jimp
|
||||||
pngSuite.add('jimp-buffer-buffer', {
|
pngSuite.add('jimp-buffer-buffer', {
|
||||||
defer: true,
|
defer: true,
|
||||||
fn: function (deferred) {
|
fn: async function (deferred) {
|
||||||
jimp.read(inputPngBuffer, function (err, image) {
|
const image = await Jimp.read(inputPngBuffer);
|
||||||
if (err) {
|
await image
|
||||||
throw err;
|
.resize({ w: width, h: heightPng, mode: Jimp.RESIZE_BICUBIC })
|
||||||
} else {
|
.getBuffer(JimpMime.png, { deflateLevel: 6, filterType: 0 });
|
||||||
image
|
deferred.resolve();
|
||||||
.resize(width, heightPng, jimp.RESIZE_BICUBIC)
|
|
||||||
.deflateLevel(6)
|
|
||||||
.filterType(0)
|
|
||||||
.getBuffer(jimp.MIME_PNG, function (err) {
|
|
||||||
if (err) {
|
|
||||||
throw err;
|
|
||||||
} else {
|
|
||||||
deferred.resolve();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}).add('jimp-file-file', {
|
}).add('jimp-file-file', {
|
||||||
defer: true,
|
defer: true,
|
||||||
fn: function (deferred) {
|
fn: async function (deferred) {
|
||||||
jimp.read(fixtures.inputPngAlphaPremultiplicationLarge, function (err, image) {
|
const image = await Jimp.read(fixtures.inputPngAlphaPremultiplicationLarge)
|
||||||
if (err) {
|
await image
|
||||||
throw err;
|
.resize({ w: width, h: heightPng, mode: Jimp.RESIZE_BICUBIC })
|
||||||
} else {
|
.write(outputPng, { deflateLevel: 6, filterType: 0 });
|
||||||
image
|
deferred.resolve();
|
||||||
.resize(width, heightPng, jimp.RESIZE_BICUBIC)
|
|
||||||
.deflateLevel(6)
|
|
||||||
.filterType(0)
|
|
||||||
.write(outputPng, function (err) {
|
|
||||||
if (err) {
|
|
||||||
throw err;
|
|
||||||
} else {
|
|
||||||
deferred.resolve();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// squoosh-cli
|
|
||||||
pngSuite.add('squoosh-cli-file-file', {
|
|
||||||
defer: true,
|
|
||||||
fn: function (deferred) {
|
|
||||||
exec(`./node_modules/.bin/squoosh-cli \
|
|
||||||
--output-dir ${os.tmpdir()} \
|
|
||||||
--resize '{"enabled":true,"width":${width},"height":${heightPng},"method":"lanczos3","premultiply":true,"linearRGB":false}' \
|
|
||||||
--oxipng '{"level":1}' \
|
|
||||||
"${fixtures.inputPngAlphaPremultiplicationLarge}"`, function (err) {
|
|
||||||
if (err) {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
deferred.resolve();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// squoosh-lib (GPLv3)
|
|
||||||
pngSuite.add('squoosh-lib-buffer-buffer', {
|
|
||||||
defer: true,
|
|
||||||
fn: function (deferred) {
|
|
||||||
const pool = new squoosh.ImagePool(os.cpus().length);
|
|
||||||
const image = pool.ingestImage(inputPngBuffer);
|
|
||||||
image.decoded
|
|
||||||
.then(function () {
|
|
||||||
return image.preprocess({
|
|
||||||
resize: {
|
|
||||||
enabled: true,
|
|
||||||
width,
|
|
||||||
height: heightPng,
|
|
||||||
method: 'lanczos3',
|
|
||||||
premultiply: true,
|
|
||||||
linearRGB: false
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.then(function () {
|
|
||||||
return image.encode({
|
|
||||||
oxipng: {
|
|
||||||
level: 1
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.then(function () {
|
|
||||||
return pool.close();
|
|
||||||
})
|
|
||||||
.then(function () {
|
|
||||||
return image.encodedWith.oxipng;
|
|
||||||
})
|
|
||||||
.then(function () {
|
|
||||||
deferred.resolve();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// mapnik
|
// mapnik
|
||||||
|
Loading…
x
Reference in New Issue
Block a user