Hello! I recently made a [benchmark](https://play.nim-lang.org/#ix=2LG0) and 
the results really puzzle me. In this benchmark I compare the sorting speed of 
a sequence of strings versus a seq of array[N, char]. The results are the 
following:
    
    
    
    Sort string:
      Collected 10000 samples in 0.06868 seconds
      Average time: 0.006417 ms
      Stddev  time: 0.002929 ms
      Min     time: 0.001841 ms
      Max     time: 0.02288 ms
    
    Sort char arrays:
      Collected 10000 samples in 0.08591 seconds
      Average time: 0.008137 ms
      Stddev  time: 0.004873 ms
      Min     time: 0.002683 ms
      Max     time: 0.3198 ms
    
    
    
    Run

Strings are faster than array of char! I would not expect that given strings 
have an indirection, while array char have better data locality. Can you offer 
an explanation for that? I made sure the string/array char comparison procs use 
the same logic. Note: doesn't run on playground because it requires Nim devel.

Reply via email to