# Improving an algorithm that compute gps distances

**URL:** <https://discourse.julialang.org/t/improving-an-algorithm-that-compute-gps-distances/38213>\
**Category:** Performance\
**Tags:** tullio\
**Created:** [April 26, 2020, 12:46am UTC](https://discourse.julialang.org/t/improving-an-algorithm-that-compute-gps-distances/38213 "2020-04-26T00:46:03Z")\
**Posts on this page:** 1\
**Showing post:** 38

<div class="post-metadata">

**Author:** ![cgarciae](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cgarciae/32/14366_2.png) [@cgarciae](https://discourse.julialang.org/u/cgarciae)\
**Post date:** [April 26, 2020, 7:42pm UTC](https://discourse.julialang.org/t/improving-an-algorithm-that-compute-gps-distances/38213/38 "2020-04-26T19:42:10Z")

</div>

@Vasily_Pisarev You should use `np.asarray` as the end since `np.array` forces a copy of the data. I made these changes and got this numbers using 8 cores:

```julia
distances 1.744 s (40 allocations: 286.18 MiB)
distances_bcast 1.464 s (30 allocations: 95.44 MiB)
distances_threaded 330.340 ms (105 allocations: 190.82 MiB)
distances_threaded_simd 150.763 ms (104 allocations: 190.82 MiB)
dist_np_test 1.413 s (39 allocations: 95.37 MiB)
dist_jax_test 259.303 ms (8 allocations: 320 bytes)

```

code: [final.jl · GitHub](https://gist.github.com/cgarciae/a69fa609f8fcd0aacece92660b5c2315)

Wow! Julia + SIMD is amazing. I am guessing Jax doesn’t use SIMD. As noted on Twitter the allocation numbers for Jax don’t mean anything.

Thanks all! I’ve learned a lot today 😃

---

_[View the full topic](https://discourse.julialang.org/t/improving-an-algorithm-that-compute-gps-distances/38213)._
