Do you know what you are doing?
    
    
    vec.setLen(10000000)
    
    
    Run

set the length and actual position to the end. This means that next add() adds 
at position 10000000, not at position 0, so reallocations may occur. Maybe use 
newSeqOfCap() or setLen(0).

I made a similar mistake when I started with Nim, and additional did my test 
with different elements sizes:

> [https://forum.nim-lang.org/t/1964#12211](https://forum.nim-lang.org/t/1964#12211)

Generally, Nim's add() should have the same performance as C++ push-back() 
nearly.

Reply via email to