Because according to this https://github.com/frol/completely-unscientific-benchmarks/tree/master/nim compilation was done in debug mode.

It needs to be nim compile -d:release --opt:speed --out:main-nim main.nim.

2018-05-14 12:11:12
If it's in Windows, antivirus is to blame. 2018-05-14 15:57:56

Aside from the wrong compiler settings, there is also a performance regression compared to 0.17.2.

The underlying reason appears to be that in 0.18, if you have a tuple result, genericReset() is called at the beginning of the procedure, which is pretty expensive.

2018-05-15 14:32:01
I just ran the c++ raw pointer and the main_fast example from nim on my linux computer. I got 0.21 for the C++ raw pointer with g++, and 0.18 for the main_fast nim example. 2018-05-15 21:52:11

@jrenner

I just ran the c++ raw pointer and the main_fast example from nim on my linux computer. I got 0.21 for the C++ raw pointer with g++, and 0.18 for the main_fast nim example.

What compiler settings did you use, and which version? I just tried it and while it's a lot faster than the first Nim version it still takes almost twice as much time as the Ada and C++ versions on my machine (.283 and .276 seconds, respectively, vs. .547 for main_fast.nim). I used

 nim c -d:release main_fast.nim
with nim 0.18.0, as well as
 nim c -d:release --opt:speed main_fast.nim
which doesn't seem to make much difference (except perhaps slow it down a little). This was on a MacBook Pro; haven't tried it on Linux yet.

2018-05-16 00:38:50

@cantanima: see the readme for the instructions how to compile.

On my machine, if I use nim c -d:release main_fast.nim I get 0.42 seconds, but if I use what it is recommended (nim compile -d:release --passC:-flto --passL:-s --gc:markAndSweep --out:main-nim main_fast.nim), it runs in 0.18 seconds.

2018-05-16 08:23:23
@miran Ah, the impression I had from this thread was that the readme's instructions produced a slower executable. 2018-05-16 11:38:55

Nim can be consistently faster than C++ with raw pointers.

See:

2018-05-16 14:29:33

Nim is the fastest now with c target according to the updated table!

The Nim javascript target is twice as slow as plain javascript for the fast version and 4x slower for the naive main.nim version.

2018-05-17 00:11:00
<<<••12••>>>