| 1 |
# Benchmarks of popular jpeg libraries |
| 2 |
|
| 3 |
Here I compare how long it takes popular JPEG decoders to decode the below 7680*4320 image |
| 4 |
of (now defunct ?) [Cutefish OS](https://en.cutefishos.com/) default wallpaper. |
| 5 |
 |
| 6 |
|
| 7 |
## About benchmarks |
| 8 |
|
| 9 |
Benchmarks are weird, especially IO & multi-threaded programs. This library uses both of the above hence performance may |
| 10 |
vary. |
| 11 |
|
| 12 |
For best results shut down your machine, go take coffee, think about life and how it came to be and why people should |
| 13 |
save the environment. |
| 14 |
|
| 15 |
Then power up your machine, if it's a laptop connect it to a power supply and if there is a setting for performance |
| 16 |
mode, tweak it. |
| 17 |
|
| 18 |
Then run. |
| 19 |
|
| 20 |
## Benchmarks vs real world usage |
| 21 |
|
| 22 |
Real world usage may vary. |
| 23 |
|
| 24 |
Notice that I'm using a large image but probably most decoding will be small to medium images. |
| 25 |
|
| 26 |
To make the library thread safe, we do about 1.5-1.7x more allocations than libjpeg-turbo. Although, do note that the |
| 27 |
allocations do not occur at ago, we allocate when needed and deallocate when not needed. |
| 28 |
|
| 29 |
Do note if memory bandwidth is a limitation. This is not for you. |
| 30 |
|
| 31 |
## Reproducibility |
| 32 |
|
| 33 |
The benchmarks are carried out on my local machine with an AMD Ryzen 5 4500u |
| 34 |
|
| 35 |
The benchmarks are reproducible. |
| 36 |
|
| 37 |
To reproduce them |
| 38 |
|
| 39 |
1. Clone this repository |
| 40 |
2. Install rust(if you don't have it yet) |
| 41 |
3. `cd` into the directory. |
| 42 |
4. Run `cargo bench` |
| 43 |
|
| 44 |
## Performance features of the three libraries |
| 45 |
|
| 46 |
| feature | image-rs/jpeg-decoder | libjpeg-turbo | zune-jpeg | |
| 47 |
|------------------------------|-----------------------|---------------|-----------| |
| 48 |
| multithreaded | ✅ | ❌ | ❌ | |
| 49 |
| platform specific intrinsics | ✅ | ✅ | ✅ | |
| 50 |
|
| 51 |
- Image-rs/jpeg-decoder uses [rayon] under the hood but it's under a feature |
| 52 |
flag. |
| 53 |
|
| 54 |
- libjpeg-turbo uses hand-written asm for platform specific intrinsics, ported to |
| 55 |
the most common architectures out there but falls back to scalar |
| 56 |
code if it can't run in a platform. |
| 57 |
|
| 58 |
# Finally benchmarks |
| 59 |
|
| 60 |
[here] |
| 61 |
|
| 62 |
## Notes |
| 63 |
|
| 64 |
Benchmarks are ran at least once a week to catch regressions early and |
| 65 |
are uploaded to Github pages. |
| 66 |
|
| 67 |
Machine specs can be found on the other [landing page] |
| 68 |
|
| 69 |
Benchmarks may not reflect real world usage(threads, other I/O machine bottlenecks) |
| 70 |
|
| 71 |
[landing page]:https://etemesi254.github.io/posts/Zune-Benchmarks/ |
| 72 |
|
| 73 |
[here]:https://etemesi254.github.io/assets/criterion/report/index.html |
| 74 |
|
| 75 |
[libjpeg-turbo]:https://github.com/libjpeg-turbo/libjpeg-turbo |
| 76 |
|
| 77 |
[jpeg-decoder]:https://github.com/image-rs/jpeg-decoder |
| 78 |
|
| 79 |
[rayon]:https://github.com/rayon-rs/rayon |