# Comparison benchmarks (numerical)

**URL:** https://discourse.julialang.org/t/comparison-benchmarks-numerical/21665
**Category:** Meta Discussion
**Created:** [March 9, 2019, 7:54am UTC](https://discourse.julialang.org/t/comparison-benchmarks-numerical/21665 "2019-03-09T07:54:32Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Thierry-Dumont](https://avatars.discourse-cdn.com/v4/letter/t/85e7bf/32.png) [@Thierry-Dumont](https://discourse.julialang.org/u/Thierry-Dumont)
#### Post date: [March 9, 2019, 7:54am UTC](https://discourse.julialang.org/t/comparison-benchmarks-numerical/21665/1 "2019-03-09T07:54:33Z")

</div>

Benchmarks are often not very interesting for people doing numerics. I have (actually with the help of two colleagues) tried to make simple but (we hope) interesting numerical benchmarks. We focused on coding and testing numerical algorithms; as an example, consider Gaussian elimination: this is something you will not use in practice, as you will use, say, lapack routines; but Gaussian elimination is a prototype of array manipulation.  
We have compared C++, Python, Python+Pythran, Python+Numba (with some variations) on a small set of problems)., ranging from very simple ones (linear combination) to Weno solution of (simple) hyperbolic PDE problems.  
But we are not sure that our Julia coding cannot be improved. If someone wants to have a look, to, propose improvements, you are welcome.

Everything is on Github: [here](https://github.com/Thierry-Dumont/BenchmarksPythonJuliaAndCo)

Thierry Dumont, Lyon -France-

---

<div class="post-metadata">

### Author: ![Tero\_Frondelius](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tero_frondelius/32/7629_2.png) [@Tero\_Frondelius](https://discourse.julialang.org/u/Tero_Frondelius)
#### Post date: [March 9, 2019, 8:14am UTC](https://discourse.julialang.org/t/comparison-benchmarks-numerical/21665/2 "2019-03-09T08:14:17Z")

</div>

Results are behind so many clicks, I copied them for convenience:

| Type | f | g | implicit |
| --- | --- | --- | --- |
| C+±lambda | 1.012 | 1.007 | none |
| C+±Pointer | 0.988 | 1.004 | 0.996 |
| Py | 16.21 | 19.43 | 9.359 |
| Pythran | 1.045 | 1.101 | 0.759 |
| Numba | 1.896 | 2.758 | 1.158 |
| Ju | 1.408 | 0.893 | 0.816 |

---

<div class="post-metadata">

### Author: ![Elrod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elrod/32/22461_2.png) [@Elrod](https://discourse.julialang.org/u/Elrod)
#### Post date: [March 9, 2019, 8:35am UTC](https://discourse.julialang.org/t/comparison-benchmarks-numerical/21665/3 "2019-03-09T08:35:31Z")

</div>

Those are the Callback results. 3 through 8 on the menu on the right show different benchmarks:  
[https://github.com/Thierry-Dumont/BenchmarksPythonJuliaAndCo/wiki/4-The-Weno-benchmark](https://github.com/Thierry-Dumont/BenchmarksPythonJuliaAndCo/wiki/4-The-Weno-benchmark)

I didn’t look at the Julia code, but skimming through the benchmarks, it looks like Julia did quite well.

EDIT: I haven’t actually messed with sparse matrices, but I’m surprised all the languages seemed to hang around 3x slower than C++ for many of those benchmarks. I would have thought runtime is dominated by a sparse matrix library?

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [March 9, 2019, 10:51am UTC](https://discourse.julialang.org/t/comparison-benchmarks-numerical/21665/4 "2019-03-09T10:51:13Z")

</div>

There are a lot of missing `@inbounds` from what I saw in a quick skim.

---

<div class="post-metadata">

### Author: ![Roger-luo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/roger-luo/32/3399_2.png) [@Roger-luo](https://discourse.julialang.org/u/Roger-luo)
#### Post date: [March 9, 2019, 11:04am UTC](https://discourse.julialang.org/t/comparison-benchmarks-numerical/21665/5 "2019-03-09T11:04:20Z")

</div>

I think they disabled bounds check in the script with

```julia
julia --check-bounds=no -O 3 main.jl

```

---

<div class="post-metadata">

### Author: ![foobar\_lv2](https://avatars.discourse-cdn.com/v4/letter/f/ee59a6/32.png) [@foobar\_lv2](https://discourse.julialang.org/u/foobar_lv2)
#### Post date: [March 9, 2019, 11:08am UTC](https://discourse.julialang.org/t/comparison-benchmarks-numerical/21665/6 "2019-03-09T11:08:21Z")

</div>

Also, the stiffness data wants to be SArray/MArray. For C++ you tell the compiler about the size of your tensors, while the julia compiler does not get that info. Since the sizes are 2 x 3 x 6, i.e. tiny, this can make a very large difference. (you don’t need to hard-code sizes; a type-unstable function boundary for entering the hot loop is very pragmatic and fast)

---

<div class="post-metadata">

### Author: ![Thierry-Dumont](https://avatars.discourse-cdn.com/v4/letter/t/85e7bf/32.png) [@Thierry-Dumont](https://discourse.julialang.org/u/Thierry-Dumont)
#### Post date: [March 9, 2019, 11:26am UTC](https://discourse.julialang.org/t/comparison-benchmarks-numerical/21665/7 "2019-03-09T11:26:16Z")

</div>

> I think they disabled bounds check in the script with
> 
> > julia --check-bounds=no -O 3 main.jl |

Yes, no need in the source code.

---

<div class="post-metadata">

### Author: ![Thierry-Dumont](https://avatars.discourse-cdn.com/v4/letter/t/85e7bf/32.png) [@Thierry-Dumont](https://discourse.julialang.org/u/Thierry-Dumont)
#### Post date: [March 9, 2019, 11:29am UTC](https://discourse.julialang.org/t/comparison-benchmarks-numerical/21665/8 "2019-03-09T11:29:49Z")

</div>

> Also, the stiffness data wants to be SArray/MArray. For C++ you tell the  
> compiler about the size of your tensors, while the julia compiler does  
> not get that info. Since the sizes are 2 x 3 x 6, i.e. tiny, this can  
> make a very large difference. (you don’t need to hard-code sizes; a  
> type-unstable function boundary for entering the hot loop is very  
> pragmatic and fast)

Very interesting.  
You can propose a modification (that is to say a pull request) 🙂  
t.
