# Julia programs now shown on benchmarks game website

**URL:** https://discourse.julialang.org/t/julia-programs-now-shown-on-benchmarks-game-website/17722
**Category:** Community
**Tags:** announcement
**Created:** [November 19, 2018, 5:44pm UTC](https://discourse.julialang.org/t/julia-programs-now-shown-on-benchmarks-game-website/17722 "2018-11-19T17:44:02Z")
**Posts on this page:** 20
**Page:** 3

<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 23, 2018, 2:43pm UTC](https://discourse.julialang.org/t/julia-programs-now-shown-on-benchmarks-game-website/17722/42 "2018-11-23T14:43:06Z")

</div>

With regards to using packages, the benchmarks are so simple there isn’t much point to packages imo, and there is value in having completely self contained examples that can be copy pasted.

Of course one could use e.g StaticArrays.jl for the nobody benchmark but showing how one can create their own static vector in a few lines shows off julia more than hiding it behind a package imo.

---

<div class="post-metadata">

### Author: ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)
#### Post date: [November 23, 2018, 4:51pm UTC](https://discourse.julialang.org/t/julia-programs-now-shown-on-benchmarks-game-website/17722/43 "2018-11-23T16:51:38Z")

</div>

See also my [Julia needs work at "Benchmark Game": numbers seem off up to 100x slower, maybe "Julia AOT" entries needed?](https://discourse.julialang.org/t/julia-needs-work-at-benchmark-game-numbers-seem-off-up-to-100x-slower-maybe-julia-aot-entries-needed/17915)

---

<div class="post-metadata">

### Author: ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)
#### Post date: [December 6, 2018, 11:30am UTC](https://discourse.julialang.org/t/julia-programs-now-shown-on-benchmarks-game-website/17722/44 "2018-12-06T11:30:12Z")

</div>

Aren’t the programs in Kristofer’s repo in good shape? I believe some or all of them should be submitted. I guess I could (but should I)? I don’t want to take anyone’s credit.

I decided to look into one of the programs that didn’t have a Julia implementation (I see however now it’s in Kristofer’s repo), and to translate this fastest [C++] non-multi-threaded version:

[https://benchmarksgame-team.pages.debian.net/benchmarksgame/program/spectralnorm-gpp-2.html](https://benchmarksgame-team.pages.debian.net/benchmarksgame/program/spectralnorm-gpp-2.html)

It uses Eigen library, and since that’s allowed, I guess we could use similar [Julia] libraries, or even the Julia Eigen wrapper.

However, I just started with translating the commented out “EQUIVALENT MATLAB IMPLEMENTATION”. It’s trivial to do, but I opted to try the [MATLAB to Julia translator | MATLAB to Julia converter](http://sciencecow.mit.edu/matlab-to-julia/) translator anyway. I ended up with this (maybe it just isn’t “EQUIVALENT”, anyone know what’s wrong?) that’s fast on my very old laptop but wrong:

```julia
julia> function approximate(n)
       A = zeros(n,n)
         for i=1:n
           for j=1:n
             A[i,j] = 1.0/((i+j)*(i+j+1)/2.0 + i+1.0)
           end
         end
         u = ones(n,1)
         v = zeros(n,1)
         for i=1:10
           v = A'*(A*u)
           u = A'*(A*v)
         end
         sqrt((u'*v)/(v'*v))
       end
approximate (generic function with 1 method)

julia> @time approximate(5500)
  5.461645 seconds (9.13 k allocations: 232.940 MB, 0.72% gc time)
1×1 Array{Float64,2}:
 0.361967

```

The translator got this line wrong (anyone know why? and I should file a bug):

sqrt((u"\*v)/(v"\*v))

and I changed integers to floats here: A[i,j] = 1.0/((i+j)\*(i+j+1)/2.0 + i+1.0)

I got the same result as expected and seems same speed (was just checking).

I opened um my MATLAB clone, Octave to just make sure, and I get the same number eventually. Probably after minutes, ten[s?]. At least Julia is way faster, can anyone compare real MATLAB to Julia for me?

---

<div class="post-metadata">

### Author: ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)
#### Post date: [December 6, 2018, 12:36pm UTC](https://discourse.julialang.org/t/julia-programs-now-shown-on-benchmarks-game-website/17722/45 "2018-12-06T12:36:57Z")

</div>

> [@Palli](#):
>
> for j=1:n A[i,j] =

You access the matrix in a suboptimal pattern. Try switching the order of the for loops

---

<div class="post-metadata">

### Author: ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)
#### Post date: [December 6, 2018, 4:02pm UTC](https://discourse.julialang.org/t/julia-programs-now-shown-on-benchmarks-game-website/17722/46 "2018-12-06T16:02:34Z")

</div>

> [@baggepinnen](#):
>
> You access the matrix in a suboptimal pattern.

Thanks, I assumed they had good MATLAB code, and I didn’t look into row vs. column major (I assumed they did differently, though stating “EQUIVALENT”).

Still of course I get the same wrong result.

This however doesn’t change the timing for Julia at least. And for Octave I gave up waiting.

For lower number/quicker I get about 6 to 7 seconds either way for 550 (sometimes the “better” version is faster sometimes the other).

While in Julia I get:

```julia
julia> @time approximate(550)
  0.049661 seconds (70 allocations: 2.491 MB)
1×1 Array{Float64,2}:
 0.361967

```

---

<div class="post-metadata">

### Author: ![Juan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juan/32/7657_2.png) [@Juan](https://discourse.julialang.org/u/Juan)
#### Post date: [December 12, 2018, 12:56am UTC](https://discourse.julialang.org/t/julia-programs-now-shown-on-benchmarks-game-website/17722/47 "2018-12-12T00:56:51Z")

</div>

There is also a “Recursive Fibonacci Benchmark using top languages on Github”.

> **[GitHub - drujensen/fib: Performance Benchmark of top Github languages](https://github.com/drujensen/fib)**
>
> Performance Benchmark of top Github languages. Contribute to drujensen/fib development by creating an account on GitHub.

It would be nice to do it better.

---

<div class="post-metadata">

### Author: ![igouy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/igouy/32/8524_2.png) [@igouy](https://discourse.julialang.org/u/igouy)
#### Post date: [December 12, 2018, 9:14pm UTC](https://discourse.julialang.org/t/julia-programs-now-shown-on-benchmarks-game-website/17722/48 "2018-12-12T21:14:34Z")

</div>

[From HN](https://news.ycombinator.com/item?id=18094984) — _"ok, owner of the repo here. So this project was purely to show the macro differences between interpreted ruby and compiled crystal to beginner ruby devs at a meet up._  
_…_  
_I didn’t expect to get a memoized version of every language and really don’t think comparing them from a performance benchmark makes much sense."_

_fyi_ The same comparison was removed from the benchmarks game and replaced with tasks that were still toy but more than a dozen lines.

> **[contributed-source-code/shootout/fibo · master · The Computer Language...](https://salsa.debian.org/benchmarksgame-team/archive-alioth-benchmarksgame/tree/master/contributed-source-code/shootout/fibo)**
>
> Archive of the, now deprecated Debian Alioth, benchmarks game project and "shootout" project.

> **[contributed-source-code/shootout/recursive · master · The Computer Language...](https://salsa.debian.org/benchmarksgame-team/archive-alioth-benchmarksgame/tree/master/contributed-source-code/shootout/recursive)**
>
> Archive of the, now deprecated Debian Alioth, benchmarks game project and "shootout" project.

---

<div class="post-metadata">

### Author: ![Juan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juan/32/7657_2.png) [@Juan](https://discourse.julialang.org/u/Juan)
#### Post date: [December 18, 2018, 11:46am UTC](https://discourse.julialang.org/t/julia-programs-now-shown-on-benchmarks-game-website/17722/49 "2018-12-18T11:46:10Z")

</div>

Maybe this can be used for further improvement of the binary-trees benchmark.

> **[GitHub - tonyrubak/benchmark: Julia Implementations of Computer Language...](https://github.com/tonyrubak/benchmark)**
>
> Julia Implementations of Computer Language Benchmark Game - GitHub - tonyrubak/benchmark: Julia Implementations of Computer Language Benchmark Game

It uses a TypedArena allocator and shows it’s fourfold faster than the default allocator.

---

<div class="post-metadata">

### Author: ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)
#### Post date: [December 18, 2018, 1:26pm UTC](https://discourse.julialang.org/t/julia-programs-now-shown-on-benchmarks-game-website/17722/50 "2018-12-18T13:26:34Z")

</div>

Probably not - the [current solution](https://github.com/KristofferC/BenchmarksGame.jl/blob/master/binarytrees/binarytree-fast.jl) is 2 times slower than the fastest solution, while the linked version is ~5x slower 😉

---

<div class="post-metadata">

### Author: ![igouy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/igouy/32/8524_2.png) [@igouy](https://discourse.julialang.org/u/igouy)
#### Post date: [December 18, 2018, 4:58pm UTC](https://discourse.julialang.org/t/julia-programs-now-shown-on-benchmarks-game-website/17722/51 "2018-12-18T16:58:00Z")

</div>

> Please don’t implement your own custom [“arena”](http://www.stroustrup.com/bs_faq2.html#placement-delete) or “memory pool” or “free list” - they will not be accepted.

> **[binary-trees description (Benchmarks Game)](https://benchmarksgame-team.pages.debian.net/benchmarksgame/description/binarytrees.html#binarytrees)**
>
> What the binary-trees benchmarks game programs should do.

---

<div class="post-metadata">

### Author: ![Orbots](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/orbots/32/3392_2.png) [@Orbots](https://discourse.julialang.org/u/Orbots)
#### Post date: [December 18, 2018, 10:55pm UTC](https://discourse.julialang.org/t/julia-programs-now-shown-on-benchmarks-game-website/17722/52 "2018-12-18T22:55:54Z")

</div>

If such a typed pool was part of the general registry we could use it. The fastest c++ versions use either a boost memory pool or some pool from apache. You won’t beat the @sdanisch version, but you’ll also have something that could be used for something other than filling memory with tree nodes and then deallocating all of them as efficiently as possible.

---

<div class="post-metadata">

### Author: ![Orbots](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/orbots/32/3392_2.png) [@Orbots](https://discourse.julialang.org/u/Orbots)
#### Post date: [December 18, 2018, 11:31pm UTC](https://discourse.julialang.org/t/julia-programs-now-shown-on-benchmarks-game-website/17722/53 "2018-12-18T23:31:15Z")

</div>

I took a crack at TypedPool implementation for this. I needed TypedPools for something else I was doing.

> <https://gist.github.com/Orbots/d1ead35efadb746cfd99430d4bef8532>

the immutable StructPool solution was marginally slower than the @sdanisch solution when freeing the pools in one go, but about 2x slower when deleting the nodes individually.

---

<div class="post-metadata">

### Author: ![Orbots](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/orbots/32/3392_2.png) [@Orbots](https://discourse.julialang.org/u/Orbots)
#### Post date: [December 19, 2018, 12:35am UTC](https://discourse.julialang.org/t/julia-programs-now-shown-on-benchmarks-game-website/17722/54 "2018-12-19T00:35:04Z")

</div>

I see MemoryArena is registered.

Updated the gist with a MemoryArena version that is as close to possible as the current solution ( using threading ). I’m seeing pretty good timings.

env JULIA\_NUM\_THREADS=4 julia binarytrees-MemoryPool.jl  
stretch tree of depth 6 check: 127  
32 trees of depth 4 check: 992  
long lived tree of depth 5 check: 63  
0.198965 seconds (540.90 k allocations: 27.119 MiB)  
stretch tree of depth 22 check: 8388607  
2097152 trees of depth 4 check: 65011712  
524288 trees of depth 6 check: 66584576  
131072 trees of depth 8 check: 66977792  
32768 trees of depth 10 check: 67076096  
8192 trees of depth 12 check: 67100672  
2048 trees of depth 14 check: 67106816  
512 trees of depth 16 check: 67108352  
128 trees of depth 18 check: 67108736  
32 trees of depth 20 check: 67108832  
long lived tree of depth 21 check: 4194303  
2.291580 seconds (106 allocations: 5.297 KiB)

=========

env JULIA\_NUM\_THREADS=4 julia binarytrees-current.jl  
Thread count: 4  
stretch tree of depth 6 check: 127  
32 trees of depth 4 check: 992  
long lived tree of depth 5 check: 63  
0.306586 seconds (1.34 M allocations: 67.345 MiB, 4.36% gc time)  
stretch tree of depth 22 check: 8388607  
2097152 trees of depth 4 check: 65011712  
524288 trees of depth 6 check: 66584576  
131072 trees of depth 8 check: 66977792  
32768 trees of depth 10 check: 67076096  
8192 trees of depth 12 check: 67100672  
2048 trees of depth 14 check: 67106816  
512 trees of depth 16 check: 67108352  
128 trees of depth 18 check: 67108736  
32 trees of depth 20 check: 67108832  
long lived tree of depth 21 check: 4194303  
1.923280 seconds (219 allocations: 153.674 MiB, 3.44% gc time)

---

<div class="post-metadata">

### Author: ![Olof\_Salberger](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/olof_salberger/32/4850_2.png) [@Olof\_Salberger](https://discourse.julialang.org/u/Olof_Salberger)
#### Post date: [January 9, 2019, 9:55am UTC](https://discourse.julialang.org/t/julia-programs-now-shown-on-benchmarks-game-website/17722/55 "2019-01-09T09:55:04Z")

</div>

So we have implementations that are much faster than the ones currently on the benchmark game website. Do we know when it’ll be updated with the faster solutions?

---

<div class="post-metadata">

### Author: ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)
#### Post date: [January 9, 2019, 11:08am UTC](https://discourse.julialang.org/t/julia-programs-now-shown-on-benchmarks-game-website/17722/56 "2019-01-09T11:08:59Z")

</div>

Whenever someone takes the initiative 🙂 I meant to kick things off, but higher priority items kept rolling in…  
@kristoffer.carlsson might have a plan about it as well… I’m guessing he’s having the same problem as me!  
Seems also like the bar is pretty high for updating the code, so I guess everyone is a bit intimidated - or doesn’t want to waste time without going anywhere 😉

---

<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: [January 9, 2019, 12:08pm UTC](https://discourse.julialang.org/t/julia-programs-now-shown-on-benchmarks-game-website/17722/57 "2019-01-09T12:08:48Z")

</div>

I just updated the spectralnorm benchmarks. It wasn’t that hard. [https://salsa.debian.org/benchmarksgame-team/benchmarksgame/issues/90](https://salsa.debian.org/benchmarksgame-team/benchmarksgame/issues/90).

However, I then noticed that someone had already updated the spectralnorm with a version that was very similar to the one I contributed! So now we have two benchmarks with very similar running times [spectral-norm (Benchmarks Game)](https://benchmarksgame-team.pages.debian.net/benchmarksgame/performance/spectralnorm.html).

We are of course losing against the compiled languages due to overhead in startup and function compilation.

---

<div class="post-metadata">

### Author: ![ImreSamu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/imresamu/32/20677_2.png) [@ImreSamu](https://discourse.julialang.org/u/ImreSamu)
#### Post date: [January 9, 2019, 2:43pm UTC](https://discourse.julialang.org/t/julia-programs-now-shown-on-benchmarks-game-website/17722/58 "2019-01-09T14:43:33Z")

</div>

All “julia” issues ( open + closed )

- [Issues · The Computer Language Benchmarks Game / benchmarksgame · GitLab](https://salsa.debian.org/benchmarksgame-team/benchmarksgame/issues?scope=all&utf8=%E2%9C%93&state=all&search=julia)

---

<div class="post-metadata">

### Author: ![igouy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/igouy/32/8524_2.png) [@igouy](https://discourse.julialang.org/u/igouy)
#### Post date: [January 9, 2019, 2:58pm UTC](https://discourse.julialang.org/t/julia-programs-now-shown-on-benchmarks-game-website/17722/59 "2019-01-09T14:58:28Z")

</div>

> [@kristoffer.carlsson](#):
>
> So now we have two benchmarks with very similar running times

If that’s thought to be a problem, someone authorative can ask for one to be removed.

---

<div class="post-metadata">

### Author: ![tomaklutfu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomaklutfu/32/2411_2.png) [@tomaklutfu](https://discourse.julialang.org/u/tomaklutfu)
#### Post date: [January 9, 2019, 4:13pm UTC](https://discourse.julialang.org/t/julia-programs-now-shown-on-benchmarks-game-website/17722/60 "2019-01-09T16:13:38Z")

</div>

It was me. For the `fasta` problem I did not use `ccall` at the end. Obviously, I was translating from `C` and `ccall` one was a little faster. However, I would like to help if I catch something. I think `binarytree` problem can be improved by using `Union{Node, nothing}` instead of type unstable version. Fast version in the [https://github.com/KristofferC/BenchmarksGame.jl/blob/master/binarytrees/binarytree-fast.jl](https://github.com/KristofferC/BenchmarksGame.jl/blob/master/binarytrees/binarytree-fast.jl) does not count fair because it implements a pool instead of the directly using julia’s `GC`.  
Ref.

> Please don’t implement your own custom [“arena”](http://www.stroustrup.com/bs_faq2.html#placement-delete) or “memory pool” or “free list” - they will not be accepted

---

<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: [January 9, 2019, 4:18pm UTC](https://discourse.julialang.org/t/julia-programs-now-shown-on-benchmarks-game-website/17722/61 "2019-01-09T16:18:01Z")

</div>

I had [add faster binarytree · JuliaPerf/BenchmarksGame.jl@dab054a · GitHub](https://github.com/KristofferC/BenchmarksGame.jl/commit/dab054af4edc31dad7a0056c27b8df9012d17cc7#diff-70ddc22df2f12e71095a7c179351602e) before that one which used the `Union`.

[Previous page](https://discourse.julialang.org/t/julia-programs-now-shown-on-benchmarks-game-website/17722.md?page=2)

[Next page](https://discourse.julialang.org/t/julia-programs-now-shown-on-benchmarks-game-website/17722.md?page=4)
