Barely anything at all, in fact I decided to run a little experiment:
    
    
    [peter /tmp ] $ cat test.nim
    import json
    
    var x = newJArray()
    
    for i in 0..10_000_000:
      x.add newJString("Hello world")
      x.add newJBool(true)
    [peter /tmp ] $ cat test2.nim
    type
      NodeValueKind = enum
        nvString
        nvBool
      
      NodeValue = ref object
        case kind: NodeValueKind
        of nvString:
          stringValue: string
        of nvBool:
          boolValue: bool
    
    var x: seq[NodeValue]
    
    for i in 0..10_000_000:
      x.add NodeValue(kind: nvString, stringValue: "Hello world")
      x.add NodeValue(kind: nvBool, boolValue: true)
    [peter /tmp ] $ time ./test
    ./test  0.67s user 0.36s system 99% cpu 1.037 total
    [peter /tmp ] $ time ./test
    ./test  0.69s user 0.31s system 99% cpu 1.004 total
    [peter /tmp ] $ time ./test
    ./test  0.65s user 0.36s system 99% cpu 1.009 total
    [peter /tmp ] $ time ./test2
    ./test2  0.74s user 0.30s system 99% cpu 1.038 total
    [peter /tmp ] $ time ./test2
    ./test2  0.74s user 0.30s system 99% cpu 1.038 total
    [peter /tmp ] $ time ./test2
    ./test2  0.73s user 0.31s system 99% cpu 1.038 total
    
    
    Run

Both examples are compiled with 0.19.4 and the -d:release switch. Not entirely 
sure why the JSON version appears to be faster, but as far as performance goes 
I would say it's pretty good.

Reply via email to