# Moving from \`Float64\` to \`Float32\` not improving performance

**URL:** <https://discourse.julialang.org/t/moving-from-float64-to-float32-not-improving-performance/88516>\
**Category:** Performance\
**Created:** [October 10, 2022, 9:43am UTC](https://discourse.julialang.org/t/moving-from-float64-to-float32-not-improving-performance/88516 "2022-10-10T09:43:55Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [October 10, 2022, 10:19am UTC](https://discourse.julialang.org/t/moving-from-float64-to-float32-not-improving-performance/88516/2 "2022-10-10T10:19:44Z")

</div>

If you do not run this on a GPU you will not gain ~~anything~~ much from Float32. See e.g. these discussion about it [Why no Float type alias?](https://discourse.julialang.org/t/why-no-float-type-alias/87947)

I just took a glance into your code and stumbled over:

- Why is function `get_mb(heights)` local in function `function glacier_evolution_optim`. Why not just a global function with additional parameters `ela_h` and `mb_grad` ?

- And I see those collect`s like

```julia
years = collect(0:(n_years+1))

```

Later you do

```julia
for (i, y) in enumerate(years)

```

but you don’t use `i` (perhaps I missed it?), so perhaps just a

```julia
years = 0:(n_years+1)
for y in years
...

```

will do.

- The purpose of those `let` 's is not clear to me. Perhaps you developed those parts in the REPL where you needed them for scope issues. You don’t need them in the function body.

I don’t know if those issues help for performance, I didn’t try to run your code. But cleaning it up from not needed structures will help a lot to get people into the maximize-performance-game.

---

_[View the full topic](https://discourse.julialang.org/t/moving-from-float64-to-float32-not-improving-performance/88516)._
