# Topological sort (performance)

**URL:** <https://discourse.julialang.org/t/topological-sort-performance/17153>\
**Category:** Performance\
**Tags:** sort\
**Created:** [November 5, 2018, 4:27am UTC](https://discourse.julialang.org/t/topological-sort-performance/17153 "2018-11-05T04:27:55Z")\
**Posts on this page:** 1\
**Showing post:** 29

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [November 7, 2018, 2:38pm UTC](https://discourse.julialang.org/t/topological-sort-performance/17153/29 "2018-11-07T14:38:34Z")

</div>

Alright, the example in that post is better on master (4x faster):

```julia
julia> @btime inversions1($p)
  179.826 ns (21 allocations: 640 bytes)
45

```

compared to 1.0.1:

```julia
julia> @btime inversions1($p)
  717.085 ns (111 allocations: 3.44 KiB)
45

```

So while there is still a slow-down compared to the hand written loop, things are improving!  
It might not be possible to get every high level abstraction to exactly match the performance of a hand written loop but the goal is to make them close enough that it shouldn’t be a big problem in practice.

---

_[View the full topic](https://discourse.julialang.org/t/topological-sort-performance/17153)._
