I made a test, where data structure that are declared as reference works x10 
faster.
    
    
    import sequtils
    
    echo "as value"
    let prices = (1..100_000).to_seq.map(proc (i: int): float = i.float)
    proc get_prices: seq[float] = prices
    
    for _ in 1..100_000:
      discard get_prices()[2]
    echo "done"
    
    echo "as reference"
    var prices_ref: ref seq[float] = nil
    prices_ref.new
    prices_ref[] = (1..100_000).to_seq.map(proc (i: int): float = i.float)
    proc get_prices_ref: ref seq[float] = prices_ref
    
    for _ in 1..100_000:
      discard get_prices_ref()[][2]
    echo "done"
    
    
    Run

Reply via email to