I don't know if you are using nim.cfg or config.nims or neither, but once you 
decide on one (or a few) bundles of options then you can package them up for 
easy reference. E.g., you could add to your $HOME/.config/nim.cfg: 
    
    
    @if r: # Allow short alias -d:r to make fast executables
      define:danger
      checks:off
      panics:on
      --passC:"-flto"
    @end
    
    
    Run

That is still related to compiler options (sort of). Also, on "options while 
building" profile-guided optimization can often help. See 
[https://forum.nim-lang.org/t/6295](https://forum.nim-lang.org/t/6295)

Other speed related ideas..Well, most are not Nim-specific but would also apply 
to C++ or something like that, but efficient data structures, not repeating 
work, avoiding memory allocation-free cycles by re-using objects when that's 
not too hard, and so on all can matter. Some of these are sort of Nim-specific. 
E.g., if you have a `seq[T]` and can estimate its size ahead of time then 
pre-allocating that size and using `[i]` will be faster than growing up by 
`add`. Similarly, pre-sizing a `Table` can save the grow-from zero with many 
intermediate resizes costs and so on.

It's much easier to give specific guidelines. So, if you can anticipate or 
profile some small section of code as important to your overall performance and 
then post that here in the Forum then you can often get good suggestions for 
how to speed it up.

Reply via email to