# Is my understanding of a data reading benchmark correct?

**URL:** https://discourse.julialang.org/t/is-my-understanding-of-a-data-reading-benchmark-correct/23611
**Category:** Data
**Created:** [April 28, 2019, 5:31am UTC](https://discourse.julialang.org/t/is-my-understanding-of-a-data-reading-benchmark-correct/23611 "2019-04-28T05:31:00Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)
#### Post date: [April 28, 2019, 5:31am UTC](https://discourse.julialang.org/t/is-my-understanding-of-a-data-reading-benchmark-correct/23611/1 "2019-04-28T05:31:00Z")

</div>

So lately I’ve spend a lot of time developing a tool reading data from files, and I just want to understand if my benchmarking procedure is correct. Currently I do something like:

- using Benchmarktools
- @benchmark function
- @benchmark function second time

And then use the last result. But lately I’ve been thinking whether this is legit or not, since when I read data the first time, then I save it in some kind of cache as well or? If yes, how would I go about clearing this cache?

Or am I overthinking?

Kind regards

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [April 28, 2019, 6:30am UTC](https://discourse.julialang.org/t/is-my-understanding-of-a-data-reading-benchmark-correct/23611/2 "2019-04-28T06:30:18Z")

</div>

Your understanding is incorrect: the API of BenchmarkTools will take care of ignoring compilation time for you, so you only need to call the relevant macros **once**.

The package is very well documented, and the manual also explains benchmarking concepts:

[https://github.com/JuliaCI/BenchmarkTools.jl/blob/master/doc/manual.md](https://github.com/JuliaCI/BenchmarkTools.jl/blob/master/doc/manual.md)

---

<div class="post-metadata">

### Author: ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)
#### Post date: [April 28, 2019, 6:45am UTC](https://discourse.julialang.org/t/is-my-understanding-of-a-data-reading-benchmark-correct/23611/3 "2019-04-28T06:45:29Z")

</div>

Thanks! What about caching of data, I assume that if I read something from a harddisk, it will put this in some kind of ram/cache, and when I read the same data again I will get an artificial improvement? Or is this also wrongly understood?

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [April 28, 2019, 6:56am UTC](https://discourse.julialang.org/t/is-my-understanding-of-a-data-reading-benchmark-correct/23611/4 "2019-04-28T06:56:16Z")

</div>

It is not very useful to confuse benchmark results with I/O speeds from within Julia, since they will be very specific to your hardware setup and how the OS handles caching. This will effectively randomize your benchmark results and make them very hard to understand.

The facilities of BenchmarkTools are for benchmarking _computations_. So you should separate that part, read in the data (a subset if the data is very large), and benchmark that separately.

You can also explore various alternatives for I/O, eg using `@time`. There is no general answer to whether caching matters, it depends on whether you think it matters for your application

---

<div class="post-metadata">

### Author: ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)
#### Post date: [April 28, 2019, 7:05am UTC](https://discourse.julialang.org/t/is-my-understanding-of-a-data-reading-benchmark-correct/23611/5 "2019-04-28T07:05:18Z")

</div>

Thanks! Now I understand. I will figure out a standardized way to a benchmark for my application then - makes sense that readspeeds are hard to benchmark because of different hardware / caching situations.
