# Variation in computation time for execution of the exact same code

**URL:** <https://discourse.julialang.org/t/variation-in-computation-time-for-execution-of-the-exact-same-code/36333>\
**Category:** Performance\
**Created:** [March 22, 2020, 5:15am UTC](https://discourse.julialang.org/t/variation-in-computation-time-for-execution-of-the-exact-same-code/36333 "2020-03-22T05:15:42Z")\
**Posts on this page:** 1\
**Showing post:** 36

<div class="post-metadata">

**Author:** ![jleman](https://avatars.discourse-cdn.com/v4/letter/j/df788c/32.png) [@jleman](https://discourse.julialang.org/u/jleman)\
**Post date:** [March 27, 2020, 6:57pm UTC](https://discourse.julialang.org/t/variation-in-computation-time-for-execution-of-the-exact-same-code/36333/36 "2020-03-27T18:57:38Z")

</div>

**Results update**

It took me a couple of days to re-write the old allocation heavy code per the static array suggestions above, but got it working and here are the results:

Old Code (allocation heavy due to use of base array and slicing approach):

```julia
455.657741 seconds (585.01 M allocations: 73.176 GiB, 88.12% gc time)

```

Revised Code (making use of static vector/matricies (StaticArrays.jl))

```julia
23.023161 seconds (71.79 M allocations: 3.910 GiB, 66.59% gc time)

```

Between the above improvements and those discussed on a related thread that’s about a 1200X improvement to my original ugly code. Thanks to all who contributed comments and suggestions!

> [@Example C vs Julia vs Python](https://discourse.julialang.org/t/example-c-vs-julia-vs-python/33120):
>
> I have been using Julia for about a year. I am an EE, not a programmer. In one of my graduate EE courses I requested to use Julia instead of C for an assignment and got the task of comparing performance of C, Julia, and Python. As a test case I did a 3D finite difference time domain simulation of electromagnetic wave propagation. I compared timing and got the following results. More detail on the approach is below. Also the code is posted below. Any suggestions for how to speed things up …

---

_[View the full topic](https://discourse.julialang.org/t/variation-in-computation-time-for-execution-of-the-exact-same-code/36333)._
