> I've been told recently that using main is not required anymore, i.e. there
> shouldn't be speed/optimization differences if you use main or not. > Can
> somebody comment on this?
It's still required but we could make the compiler do this transformation for
us. However, there are much more
performant code when you want -> sane/safe/easy defaults
-d:release causes -O3 -fno-strict-aliasing. See config/nim.cfg or
nimcache/app.c|
Thank you for the gist. You corrected some of my brainfarts as well.
Clang seems to be faster for me than gcc! Now faster than my cpp
implementation. What configurations sets gcc as standard when compiling Nim?
My results: Clang: 0m0.144s GCC: 0m0.197s
I'm on a MBP 2013 with Core i7 I7-4850HQ.
> Always use a `main` proc in Nim.
>
> \
>
> I noticed in another thread
> ([https://forum.nim-lang.org/t/1268/1#7848](https://forum.nim-lang.org/t/1268/1#7848))
> Araq telling to wrap the code in a main proc.
That thread is 3 years old. I've been told recently that using `main` is not
Yes, wrapped everything in main:
[https://gist.github.com/def-/4e4dea8f0f40ef7a77a2729148d8fe0e](https://gist.github.com/def-/4e4dea8f0f40ef7a77a2729148d8fe0e)
You could try a more recent GCC version (7.3.1 here). `nim -d:release
--gcc.options.speed="-Ofast -flto -fno-strict-aliasing
Hi def You beat me to it!
**Thank you** very much for looking into it and replying. You are right!
I don't get quite the same performance boost as you do, cpp still seems faster
but barely. Might be any number of reasons.
Do you have any more nice tricks for the nim code? Did you also wrap the
Okay. I noticed in another thread
([https://forum.nim-lang.org/t/1268/1#7848](https://forum.nim-lang.org/t/1268/1#7848))
Araq telling to wrap the code in a main proc.
I did and now the speed is almost comparable to my cpp!
Nim: 0m0.197s cpp 0m0.159s
Impressive. I updated the master branch
Always use a `main` proc in Nim. Speeds up the execution from 0.80 s to 0.15 s
in this case for me, compared to 0.20 s for the C++ version (compiled with `g++
-Ofast -flto -o main main.cpp ArrayHelpers.cpp NeuralNetwork.cpp
OptimizationProblems.cpp RandomGenerators.cpp`). You can also use
@Allin I didn't find basic2d and basic3d, in the docs the links are dead.
I have written a differential evolution algorithm in cpp and Nim.
My cpp version is faster (6-8 times) and I was hoping I could get comparable
performance with the Nim implementation. I need a hand.
Nim version:
I like the idea to make `seq` and `string` default `@[]` and `""`, we can use
`{.noinit.}` to make them `nil` if care about performance.
If you first make a mini-header file then define the functions wouldn't that
ensure that you can call a function defined below the another function
proc foo()=
bar()
proc bar()=
discard 1+1
foo()
the code above would result in an error
Very interesting!
Since there's been some take about reducing the standard library, and because I
was curious, I decided to generate some statistics for usage of the standard
library in GitHub projects. I used the top 1000 most starred Nim projects on
GitHub.
* * *
**Results:**
15 matches
Mail list logo