Skip to content

性能

对该模块相对于替代方案的性能进行基准测试。

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

启用缓存(默认)并使用 8 个以上核心的计算机(尤其是具有较大 L1/L2 CPU 缓存的计算机)可以期待更高的 libvips 性能。

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

相关(解)压缩库的 I/O 限制通常将决定最大吞吐量。

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

竞争者

¥Contenders

  • jimp v1.6.0 - 纯 JavaScript 中的图片处理。

    ¥jimp v1.6.0 - Image processing in pure JavaScript.

  • imagemagick v0.1.3 - 仅支持文件系统和 “has been unmaintained for a long time”。

    ¥imagemagick v0.1.3 - Supports filesystem only and “has been unmaintained for a long time”.

  • gm v1.25.1 - GraphicsMagick 的 gm 命令行实用程序的全功能封装器,但 “已停用”。

    ¥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 - 禁用 libvips 内的缓存以确保公平比较。

    ¥sharp v0.34.0 / libvips v8.16.1 - Caching within libvips disabled to ensure a fair comparison.

环境

¥Environment

AMD64

ARM64

任务:JPEG

¥Task: JPEG

解压缩 2725x2225 JPEG 图片,使用 Lanczos 3 重采样(如果可用)将大小调整为 720x588,然后以 “quality” 设置 80 压缩为 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.

注意:jimp 不支持 Lanczos 3,而是使用双三次重采样。

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

结果:JPEG (AMD64)

¥Results: JPEG (AMD64)

模块输入输出操作数/秒加速
jimpbufferbuffer2.351.0
imagemagickfilefile10.514.5
gmbufferbuffer11.675.0
gmfilefile11.755.1
sharpstreamstream60.7225.8
sharpfilefile62.3726.5
sharpbufferbuffer65.1527.7

结果:JPEG (ARM64)

¥Results: JPEG (ARM64)

模块输入输出操作数/秒加速
jimpbufferbuffer2.131.0
imagemagickfilefile12.956.1
gmbufferbuffer13.536.4
gmfilefile13.526.4
sharpstreamstream46.5821.9
sharpfilefile48.4222.7
sharpbufferbuffer50.1623.6

任务:PNG

¥Task: PNG

解压缩 2048x1536 RGBA PNG 图片,预乘 Alpha 通道,使用 Lanczos 3 重采样(如果可用)将大小调整为 720x540,取消预乘,然后使用 “default” zlib 压缩级别 6 压缩为 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.

注意:jimp 不支持预乘/取消预乘。

¥Note: jimp does not support premultiply/unpremultiply.

结果:PNG (AMD64)

¥Results: PNG (AMD64)

模块输入输出操作数/秒加速
gmfilefile8.661.0
imagemagickfilefile8.791.0
jimpbufferbuffer11.261.3
sharpfilefile27.933.2
sharpbufferbuffer28.693.3

结果:PNG (ARM64)

¥Results: PNG (ARM64)

模块输入输出操作数/秒加速
gmfilefile9.651.0
imagemagickfilefile9.721.0
jimpbufferbuffer10.681.1
sharpfilefile23.902.5
sharpbufferbuffer24.482.5

运行基准测试

¥Running the benchmark test

需要 Docker。

¥Requires Docker.

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