# How to benchmark in-place functions?

**URL:** https://discourse.julialang.org/t/how-to-benchmark-in-place-functions/36493
**Category:** Performance
**Tags:** question
**Created:** [March 25, 2020, 1:52pm UTC](https://discourse.julialang.org/t/how-to-benchmark-in-place-functions/36493 "2020-03-25T13:52:26Z")
**Posts on this page:** 1
**Showing post:** 7

<div class="post-metadata">

### Author: ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)
#### Post date: [March 25, 2020, 2:36pm UTC](https://discourse.julialang.org/t/how-to-benchmark-in-place-functions/36493/7 "2020-03-25T14:36:35Z")

</div>

I suspect you’re seeing an artifact of the amortized constant time of `push!` (see [algorithms - Why is push\_back in C++ vectors constant amortized? - Computer Science Stack Exchange](https://cs.stackexchange.com/a/9382) for some discussion). The longer the vector gets, the less frequently its capacity is changed, so the more likely it is that your benchmark loop will happen to catch a set of pushes that do not contain a capacity change (and thus don’t contain any memory allocation).

In other words: don’t worry about those few extra nanoseconds and the one allocation here 🙂

---

_[View the full topic](https://discourse.julialang.org/t/how-to-benchmark-in-place-functions/36493)._
