Git Product home page Git Product logo

avif-benchmark's Introduction

AVIF vs WebP Conversion Benchmark

This repository is a companion for vercel/next.js#20765, which aims to bring first-class support for the AVIF image format, thanks to sharp. This repo is helpful to compare the time taken to convert images to WebP & AVIF (or actually any format that sharp can support).

What the benchmark does

Every run reads the source image from disk, rotates (if there's EXIF data asking to do it), reads metadata, and converts the image to the target format (without writing to disk). I'm not including the write in the benchmark because it doesn't affect the image conversion.

Usage

./run-bench.sh <file-path> <avif/webp> <run-count>

Example

./run-bench.sh pexels-sam-kolder-2387871-S.jpg avif 100

Sample Results

All benchmarks were run on my mid-2014 13" MacBook Pro with a 2.6 GHz Dual-Core Intel Core i5 processor and 8 GB 1600 MHz DDR3 RAM (with Chrome, Firefox, MS Edge, Slack & VSCode running).

Test images from โ€”

  1. https://www.pexels.com/photo/person-sitting-in-front-of-the-taj-mahal-2387871/ (JPG)
  2. https://undraw.co/illustrations (PNG)

Converting a large JPG image (1920โ€Šร—โ€Š2504) to WebP (total runtime of 2m 15s for 1000 runs)

๎‚ฐ ./run-bench.sh pexels-sam-kolder-2387871-L.jpg webp 1000

Sharp pexels-sam-kolder-2387871-L.jpg -> webp Conversion (1000 runs)
Average time = .2961174730 ms

Converting a large JPG image (1920โ€Šร—โ€Š2504) to AVIF (total runtime of 2m 24s for 1000 runs)

๎‚ฐ ./run-bench.sh pexels-sam-kolder-2387871-L.jpg avif 1000

Sharp pexels-sam-kolder-2387871-L.jpg -> avif Conversion (1000 runs)
Average time = .2261837420 ms

Converting a medium JPG image (1280โ€Šร—โ€Š1669) to WebP (total runtime of 2m 16s for 1000 runs)

๎‚ฐ ./run-bench.sh pexels-sam-kolder-2387871-M.jpg webp 1000

Sharp pexels-sam-kolder-2387871-M.jpg -> webp Conversion (1000 runs)
Average time = .2761548210 ms

Converting a medium JPG image (1280โ€Šร—โ€Š1669) to AVIF (total runtime of 2m 23s for 1000 runs)

๎‚ฐ ./run-bench.sh pexels-sam-kolder-2387871-M.jpg avif 1000

Sharp pexels-sam-kolder-2387871-M.jpg -> avif Conversion (1000 runs)
Average time = .2373165780 ms

Converting a small JPG image (640โ€Šร—โ€Š834) to WebP (total runtime of 2m 23s)

๎‚ฐ ./run-bench.sh pexels-sam-kolder-2387871-S.jpg webp 1000

Sharp pexels-sam-kolder-2387871-S.jpg -> webp Conversion (1000 runs)
Average time = .2731627210 ms

Converting a small JPG image (640โ€Šร—โ€Š834) to AVIF (total runtime of 2m 25s for 1000 runs)

๎‚ฐ ./run-bench.sh pexels-sam-kolder-2387871-S.jpg avif 1000

Sharp pexels-sam-kolder-2387871-S.jpg -> avif Conversion (1000 runs)
Average time = .2406256660 ms

Converting a medium PNG image (1275โ€Šร—โ€Š916) to WebP (total runtime of 2m 15s for 1000 runs)

๎‚ฐ ./run-bench.sh undraw_new_year_2021_2neh-M.png webp 1000

Sharp undraw_new_year_2021_2neh-M.png -> webp Conversion (1000 runs)
Average time = .2583528300 ms

Converting a medium PNG image (1275โ€Šร—โ€Š916) to AVIF (total runtime of 2m 32s for 1000 runs)

๎‚ฐ ./run-bench.sh undraw_new_year_2021_2neh-M.png avif 1000

Sharp undraw_new_year_2021_2neh-M.png -> avif Conversion (1000 runs)
Average time = .2347853600 ms

About CPU and Memory usage

CPU and memory usage was very negligible (given how well optimized sharp is) and so aren't included in the results.

avif-benchmark's People

Contributors

paambaati avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.