# Gauss-Legendre Quadrature performance

**URL:** <https://discourse.julialang.org/t/gauss-legendre-quadrature-performance/52958>\
**Category:** Numerics\
**Created:** [January 6, 2021, 7:38pm UTC](https://discourse.julialang.org/t/gauss-legendre-quadrature-performance/52958 "2021-01-06T19:38:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nellatur](https://avatars.discourse-cdn.com/v4/letter/n/76d3ee/32.png) [@Nellatur](https://discourse.julialang.org/u/Nellatur)\
**Post date:** [January 6, 2021, 7:38pm UTC](https://discourse.julialang.org/t/gauss-legendre-quadrature-performance/52958/1 "2021-01-06T19:38:57Z")

</div>

Hi,

I found a benchmark set with Julia and other languages at  
[https://modelingguru.nasa.gov/docs/DOC-2676](https://modelingguru.nasa.gov/docs/DOC-2676)  
It seems that the Gauss-Legendre Quadrature case Julia is slower than Python ☹

I also found [GitHub - JuliaApproximation/FastGaussQuadrature.jl: Julia package for Gaussian quadrature](https://github.com/JuliaApproximation/FastGaussQuadrature.jl)  
Is there any updated comparison 🙂 Sorry I am too lazy to benchmark on my own…

---

<div class="post-metadata">

**Author:** ![jlchan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlchan/32/10958_2.png) [@jlchan](https://discourse.julialang.org/u/jlchan)\
**Post date:** [January 6, 2021, 8:01pm UTC](https://discourse.julialang.org/t/gauss-legendre-quadrature-performance/52958/2 "2021-01-06T20:01:22Z")

</div>

Looking at the code, I’m suspicious of their Julia timings. They’re not using BenchmarkTools.jl or interpolation to time Julia code, so they might have picked up precompilation times.

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [January 6, 2021, 10:05pm UTC](https://discourse.julialang.org/t/gauss-legendre-quadrature-performance/52958/3 "2021-01-06T22:05:06Z")

</div>

> [@Nellatur](#):
>
> [https://modelingguru.nasa.gov/docs/DOC-2676](https://modelingguru.nasa.gov/docs/DOC-2676)

You are looking at the wrong page. Those are the 2018 results, and they are clearly a mess:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/b/0/b095d1271f96c256e2c7db241c1f9fd10f1dc95e.png)

IDL is 1000-2000x faster than Julia, while Python grows faster for larger problems (by a factor of 10x!!)

And then, for the Jacobi iterative solver, look at this

 ![image](https://global.discourse-cdn.com/julialang/original/3X/a/0/a0a16ae56a9859bdf3f7e4d1ef91e6d0fff91ece.png)  
IDL is suddenly 80x _slower_ than Julia…

Those results are garbage. Instead look at the 2019 results for Gauss-Legendre:  
(2019-results here: [https://modelingguru.nasa.gov/docs/DOC-2783](https://modelingguru.nasa.gov/docs/DOC-2783))

 ![image](https://global.discourse-cdn.com/julialang/original/3X/8/9/89206956896e973e06f7195cbc1fc7493897a59c.png)  
Julia blows IDL and python out of the water. IDL still makes no sense, though. Look at how the runtimes change for different problem sizes.

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [January 6, 2021, 10:39pm UTC](https://discourse.julialang.org/t/gauss-legendre-quadrature-performance/52958/4 "2021-01-06T22:39:11Z")

</div>

They are also using `@njit(parallel=True)` for the trigonometric Python+Numba code, while not using Julia `@threads`. This purpose of this benchmark is ostensibly to measure “function evaluation”, though most of the time is spent on array allocation.

I think the benchmarks need some thoughtful input.

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [January 7, 2021, 10:25am UTC](https://discourse.julialang.org/t/gauss-legendre-quadrature-performance/52958/5 "2021-01-07T10:25:13Z")

</div>

Aaarg. Another complaint. They have a `test_count_unique_words`, which, first of all, counts _all_ words, not _unique_ words. But they also print each line, and the results to screen, which _completely_ dwarfs the time it takes to actually count (printing a line takes ~200x as long as counting the number of words, for a fast implementation). And also, they use non-const globals.

I’m afraid this benchmark suite requires _a lot_ of input.

---

<div class="post-metadata">

**Author:** ![liuyxpp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/liuyxpp/32/9870_2.png) [@liuyxpp](https://discourse.julialang.org/u/liuyxpp)\
**Post date:** [January 7, 2021, 12:26pm UTC](https://discourse.julialang.org/t/gauss-legendre-quadrature-performance/52958/6 "2021-01-07T12:26:34Z")

</div>

Wow, such a careless (or deliberate) test appears in a link with `nasa.gov`? Unbelievable!
