Skip to content

Performance

A test to benchmark the performance of this module relative to alternatives.

Greater libvips performance can be expected with caching enabled (default) and using 8+ core machines, especially those with larger L1/L2 CPU caches.

The I/O limits of the relevant (de)compression library will generally determine maximum throughput.

Contenders

  • jimp v1.6.0 - Image processing in pure JavaScript.
  • imagemagick v0.1.3 - Supports filesystem only and “has been unmaintained for a long time”.
  • gm v1.25.1 - Fully featured wrapper around GraphicsMagick’s gm command line utility, but “has been sunset”.
  • sharp v0.34.0 / libvips v8.16.1 - Caching within libvips disabled to ensure a fair comparison.

Environment

AMD64

ARM64

Task: JPEG

Decompress a 2725x2225 JPEG image, resize to 720x588 using Lanczos 3 resampling (where available), then compress to JPEG at a “quality” setting of 80.

Note: jimp does not support Lanczos 3, bicubic resampling used instead.

Results: JPEG (AMD64)

ModuleInputOutputOps/secSpeed-up
jimpbufferbuffer2.351.0
imagemagickfilefile10.514.5
gmbufferbuffer11.675.0
gmfilefile11.755.1
sharpstreamstream60.7225.8
sharpfilefile62.3726.5
sharpbufferbuffer65.1527.7

Results: JPEG (ARM64)

ModuleInputOutputOps/secSpeed-up
jimpbufferbuffer2.131.0
imagemagickfilefile12.956.1
gmbufferbuffer13.536.4
gmfilefile13.526.4
sharpstreamstream46.5821.9
sharpfilefile48.4222.7
sharpbufferbuffer50.1623.6

Task: PNG

Decompress a 2048x1536 RGBA PNG image, premultiply the alpha channel, resize to 720x540 using Lanczos 3 resampling (where available), unpremultiply then compress as PNG with a “default” zlib compression level of 6 and without adaptive filtering.

Note: jimp does not support premultiply/unpremultiply.

Results: PNG (AMD64)

ModuleInputOutputOps/secSpeed-up
gmfilefile8.661.0
imagemagickfilefile8.791.0
jimpbufferbuffer11.261.3
sharpfilefile27.933.2
sharpbufferbuffer28.693.3

Results: PNG (ARM64)

ModuleInputOutputOps/secSpeed-up
gmfilefile9.651.0
imagemagickfilefile9.721.0
jimpbufferbuffer10.681.1
sharpfilefile23.902.5
sharpbufferbuffer24.482.5

Running the benchmark test

Requires Docker.

Terminal window
git clone https://github.com/lovell/sharp.git
cd sharp/test/bench
./run-with-docker.sh