Photo by ramzi hashisho from FreeImages

Coil is the new boy in town and is becoming increasingly popular. But why is it arousing so much interest? Well, this library is a breath of fresh air in the image loading context which nowadays is dominated by mature libraries. Coil is different because was created with Kotlin in mind. Also, it is lightweight because it uses other libraries that many Android developers are already including in their projects (Coroutines and Okhttp). If you want to know more about it, you can read this article from Colin White, the creator of Coil, or see the documentation page.

When I first read about this library I though those are good improvements, but I was curious to know how this library works compared with other well-known libraries. The goal of this article is to measure and give you a rough idea about Coil’s performance in context. To do so, we are going to compare the speed of Coil, Glide and Picasso.

What we are going to measure?

To figure out how is the performance of these libraries, an example has been implemented with each of them. This is a simple app which downloads a list of ten images and shows them in a grid layout. You can see below a screenshot of the app:

How the test app looks like

Below you have a link of the apps implemented using Glide, Picasso and Coil:

A Pixel 3 was the device used to test it. All images are visible at the same time, so these are requested almost at the same time and therefore, will be loaded almost in parallel. Two kinds of tests have been done:

The time it takes to load every single image. In order to have more accurate data, images are being downloaded ten times, so the average will be taken into account. The time it takes to load the total list of images. This number is important because the images are loading in parallel, so it can not be extrapolated from a single image. This test has been done also ten times in order to have an average.

Another important point to test is in the time spent for the first loading of images and loading them from the cache. The tests have been done twice to cover those two scenarios.

Downloading from the Network

We are going to start with the scenario where the cache is empty and the image is downloaded from the server.

Glide

In the table below you can see the time for Glide per photo with the empty cache. Notice these times are the average of ten attempts.

+------------------------+---------------+-------+-----------+

| | Elapsed time | Size | Dimension |

+------------------------+---------------+-------+-----------+

| Anna Karenina | 285ms | 80KB | 200x310 |

| To kill a mockingbird | 252ms | 80KB | 200x295 |

| The great Gatsby | 265ms | 97KB | 200x299 |

| In search of lost time | 243ms | 65KB | 200x311 |

| Don Quixote | 299ms | 72KB | 200x264 |

| Ulysses | 306ms | 64KB | 200x253 |

| Moby Dick | 307ms | 71KB | 200x287 |

| Hamlet | 324ms | 83KB | 200x304 |

| War and Peace | 337ms | 69KB | 200x302 |

| The Odyssey | 350ms | 112KB | 200x287 |

+------------------------+---------------+-------+-----------+

The following table shows the time needed to load the complete list of images, and also the average.

+---------+--------------+

| | Elapsed time |

+---------+--------------+

| Test 1 | 356ms |

| Test 2 | 396ms |

| Test 3 | 396ms |

| Test 4 | 361ms |

| Test 5 | 361ms |

| Test 6 | 474ms |

| Test 7 | 413ms |

| Test 8 | 394ms |

| Test 9 | 415ms |

| Test 10 | 379ms |

+---------+--------------+

| Average | 395ms |

+---------+--------------+

Picasso

The same for Picasso:

+------------------------+--------------+-------+------------+

| | Elapsed time | Size | Dimension |

+------------------------+--------------+-------+------------+

| Anna Karenina | 463ms | 80KB | 200x310 |

| To kill a mockingbird | 448ms | 80KB | 200x295 |

| The great Gatsby | 451ms | 97KB | 200x299 |

| In search of lost time | 450ms | 65KB | 200x311 |

| Don Quixote | 449ms | 72KB | 200x264 |

| Ulysses | 449ms | 64KB | 200x253 |

| Moby Dick | 448ms | 71KB | 200x287 |

| Hamlet | 448ms | 83KB | 200x304 |

| War and Peace | 448ms | 69KB | 200x302 |

| The Odyssey | 447ms | 112KB | 200x287 |

+------------------------+--------------+-------+------------+

And the time for the entire list of images

+---------+--------------+

| | Elapsed time |

+---------+--------------+

| Test 1 | 472ms |

| Test 2 | 465ms |

| Test 3 | 506ms |

| Test 4 | 458ms |

| Test 5 | 479ms |

| Test 6 | 474ms |

| Test 7 | 467ms |

| Test 8 | 453ms |

| Test 9 | 505ms |

| Test 10 | 456ms |

+---------+--------------+

| Average | 474ms |

+---------+--------------+

Coil

Now it’s Coil’s turn.

+------------------------+--------------+-------+------------+

| | Elapsed time | Size | Dimension |

+------------------------+--------------+-------+------------+

| Anna Karenina | 457ms | 80KB | 200x310 |

| To kill a mockingbird | 432ms | 80KB | 200x295 |

| The great Gatsby | 428ms | 97KB | 200x299 |

| In search of lost time | 431ms | 65KB | 200x311 |

| Don Quixote | 447ms | 72KB | 200x264 |

| Ulysses | 415ms | 64KB | 200x253 |

| Moby Dick | 412ms | 71KB | 200x287 |

| Hamlet | 420ms | 83KB | 200x304 |

| War and Peace | 436ms | 69KB | 200x302 |

| The Odyssey | 473ms | 112KB | 200x287 |

+------------------------+--------------+-------+------------+

Again the full list of images:

+---------+--------------+

| | Ellapsed time|

+---------+--------------+

| Test 1 | 766ms |

| Test 2 | 285ms |

| Test 3 | 322ms |

| Test 4 | 870ms |

| Test 5 | 1s 243ms |

| Test 6 | 289ms |

| Test 7 | 1s 193ms |

| Test 8 | 292ms |

| Test 9 | 327ms |

| Test 10 | 295ms |

+---------+--------------+

| Average | 588ms |

+---------+--------------+

Loading from Cache

Now the test is repeated but with the images already stored in the cache.

Glide

Let’s start loading each image:

+------------------------+---------------+-------+------------+

| | Elapsed time | Size | Dimension |

+------------------------+---------------+-------+------------+

| Anna Karenina | 52ms | 80KB | 200x310 |

| To kill a mockingbird | 32ms | 80KB | 200x295 |

| The great Gatsby | 45ms | 97KB | 200x299 |

| In search of lost time | 44ms | 65KB | 200x311 |

| Don Quixote | 45ms | 72KB | 200x264 |

| Ulysses | 59ms | 64KB | 200x253 |

| Moby Dick | 57ms | 71KB | 200x287 |

| Hamlet | 60ms | 83KB | 200x304 |

| War and Peace | 71ms | 69KB | 200x302 |

| The Odyssey | 72ms | 112KB | 200x287 |

+------------------------+---------------+-------+------------+

And now the full list of images:

+---------+--------------+

| | Ellapsed time|

+---------+--------------+

| Test 1 | 112ms |

| Test 2 | 113ms |

| Test 3 | 114ms |

| Test 4 | 113ms |

| Test 5 | 114ms |

| Test 6 | 141ms |

| Test 7 | 115ms |

| Test 8 | 115ms |

| Test 9 | 114ms |

| Test 10 | 115ms |

+---------+--------------+

| Average | 117ms |

+---------+--------------+

Picasso

The same for Picasso:

+------------------------+---------------+-------+------------+

| | Elapsed time | Size | Dimension |

+------------------------+---------------+-------+------------+

| Anna Karenina | 284ms | 80KB | 200x310 |

| To kill a mockingbird | 265ms | 80KB | 200x295 |

| The great Gatsby | 270ms | 97KB | 200x299 |

| In search of lost time | 269ms | 65KB | 200x311 |

| Don Quixote | 268ms | 72KB | 200x264 |

| Ulysses | 268ms | 64KB | 200x253 |

| Moby Dick | 267ms | 71KB | 200x287 |

| Hamlet | 267ms | 83KB | 200x304 |

| War and Peace | 266ms | 69KB | 200x302 |

| The Odyssey | 265ms | 112KB | 200x287 |

+------------------------+---------------+-------+------------+

And also the complete list of images previously cached:

+---------+--------------+

| | Elapsed time |

+---------+--------------+

| Test 1 | 290ms |

| Test 2 | 294ms |

| Test 3 | 298ms |

| Test 4 | 288ms |

| Test 5 | 296ms |

| Test 6 | 267ms |

| Test 7 | 294ms |

| Test 8 | 295ms |

| Test 9 | 297ms |

| Test 10 | 313ms |

+---------+--------------+

| Average | 293ms |

+---------+--------------+

Coil

And last but not least Coil:

+------------------------+--------------+-------+-----------+

| | Elapsed time | Size | Dimension |

+------------------------+--------------+-------+-----------+

| Anna Karenina | 116ms | 80KB | 200x310 |

| To kill a mockingbird | 93ms | 80KB | 200x295 |

| The great Gatsby | 88ms | 97KB | 200x299 |

| In search of lost time | 84ms | 65KB | 200x311 |

| Don Quixote | 78ms | 72KB | 200x264 |

| Ulysses | 76ms | 64KB | 200x253 |

| Moby Dick | 67ms | 71KB | 200x287 |

| Hamlet | 65ms | 83KB | 200x304 |

| War and Peace | 57ms | 69KB | 200x302 |

| The Odyssey | 50ms | 112KB | 200x287 |

+------------------------+--------------+-------+-----------+

Below the time to load the complete list:

+---------+--------------+

| | Elapsed time |

+---------+--------------+

| Test 1 | 118ms |

| Test 2 | 98ms |

| Test 3 | 117ms |

| Test 4 | 115ms |

| Test 5 | 138ms |

| Test 6 | 136ms |

| Test 7 | 131ms |

| Test 8 | 116ms |

| Test 9 | 94ms |

| Test 10 | 109ms |

+---------+--------------+

| Average | 117ms |

+---------+--------------+

Conclusions

For a better understanding of the results we got in the benchmarks, we can see those numbers in some charts. In the next one, you can see the result when the images are being downloaded from the network for every single image.

Glide is faster and the results of Picasso and Coil are similar.

But what about when we are loading from the cache. As you can see in the images below we have the best times for Glide in most of the cases. Coil is the second and Picasso is the last one by far.

Time to load all single images from the cache

Another important topic is the time spent loading the complete list of images. In this example, these numbers are quite important because that is the time the user waits until the entire list of images is visible. When the images are loaded from the network, Glide is the fastest one, following by Picasso, then Coil is the slowest one.

Loading from cache the results are different. Glide and Coil tie in the first position and Picasso is the slowest.

From these numbers we can draw several conclusions:

There are many scenarios to test, for instance, download large images, resize images to fit the container, etc. Therefore, I can not speak about other scenarios where the results can be quite different. As you know, the statistic is a science of large numbers, so running ten tests of each scenario is not enough to be taxative, although we can have a rough idea of performance. Glide seems to be faster in most situations, but the number is not that large in general. If you need to perform very well, or you are downloading many images maybe this is interesting for you. Also, keep in mind that maybe the result of these test change if we are using big images. For a regular app, I would say performance is not relevant. Coil is a new library, so its performance may increase in the next versions. We are comparing it with mature libraries, so let’s see how it evolves.

I would like to emphasise that performance is not everything, especially when your app is not using image loading intensively. In my case, I consider better to use Coil because it is designed to be used in Kotlin, so the code is more concise and cleaner in general. Of course, if you are looking for a very good performance at least in this scenario Glide is faster.