Skip to content

Benchmark

Eric Pailleau edited this page Feb 26, 2022 · 10 revisions

Benchmark

Disclaimer : this is a snapshot at a given time (2022-02-26). Results may differ depending data or machine used, as well projects updates can increase (or decrease) performances. Each project can provide the rare feature you are seeking. This is not a value judgment. Do your own benchmarks !

Below benchmark was done with Erlang/OTP 25.0-rc1 (non JIT) on a x86_64 GNU/Linux Laptop.

Encoding

Encoding is as efficient, and often better, than other project not using C code. In particular, standard deviation is lower in most case.

2> jason_bench:encode(15000).
*** Encode (15000)
                Range (mics)    Median (mics)   Average (mics)  Data
                                                                [{<<"abc">>,
                                                                  <<"def">>}]
      jason          0 - 71              1                2   
      jiffy                                                     N/A
      jsone          0 - 1763            1                1   
        jsx          1 - 3295            4                4   

                                                                {[{<<"abc">>,
                                                                   <<"def">>}]}
      jason          0 - 148             1                1   
      jiffy          0 - 660             1                2   
      jsone          0 - 56              1                1   
        jsx                                                     N/A

                                                                [{abc,
                                                                  <<"def">>}]
      jason          0 - 49              1                1   
      jiffy                                                     N/A
      jsone          0 - 121             1                1   
        jsx          1 - 40              4                4   

                                                                [1,2,3,4,5]
      jason          0 - 26              1                1   
      jiffy          0 - 565             2                2   
      jsone          0 - 66              1                1   
        jsx          1 - 44              4                4   

                                                                ["a","b","c",
                                                                 "d"]
      jason          0 - 45              1                1   
      jiffy          0 - 845             3                3   
      jsone          0 - 40              2                2   
        jsx          1 - 67              4                4   

                                                                [1,1.2345,
                                                                 <<"a">>]
      jason          0 - 47              1                1   
      jiffy          0 - 558             2                3   
      jsone          0 - 50              3                3   
        jsx          1 - 149             4                5   

                                                                #{<<"abc">> =>
                                                                      <<"def">>}
      jason          0 - 260             1                1   
      jiffy          0 - 427             2                2   
      jsone          0 - 52              1                1   
        jsx          1 - 33              4                4   

                                                                [1,2.3,true,
                                                                 false,null,
                                                                 atom,
                                                                 <<"string">>,
                                                                 []]
      jason          1 - 46              4                4   
      jiffy          1 - 461             4                4   
      jsone          1 - 115             4                4   
        jsx          3 - 95             14               11   

Decoding

Decoding is slower in magnitude 1.5 (using option {binary, kv}) compared to projects not using C code, due to choice of using a two step approach, lexical analyzer (Leex) then LALR-1 parser (Yecc). However this permit powerful bottom up creation of record module helpers for deeply nested JSON structures.

3> jason_bench:decode(15000).
*** Decode (15000)
                Range (mics)    Median (mics)   Average (mics)  Data
                                                                <<"{\"abc\": \"def\"}">>
      jason          1 - 290             4                5   
      jiffy          0 - 141             1                1   
      jsone          0 - 143             1                1   
        jsx          0 - 110             1                2   

                                                                <<"[1, 2, 3, 4]">>
      jason          1 - 113             3                3   
      jiffy          0 - 129             2                2   
      jsone          0 - 140             1                1   
        jsx          0 - 107             3                3   

                                                                <<"[1, 2.345, \"abc\"]">>
      jason          1 - 121             4                5   
      jiffy          0 - 196             2                2   
      jsone          0 - 116             1                1   
        jsx          1 - 102             4                4   

                                                                <<"{\"abc\" : { \"def\" : [1, 2.345, \"abc\"]} }">>
      jason          2 - 137             9                9   
      jiffy          1 - 169             4                4   
      jsone          0 - 123             3                3   
        jsx          2 - 69              4                5   

                                                                File "ex1.json"
      jason         20 - 124            29               30   
      jiffy          3 - 181             7                7   
      jsone          5 - 124             9               10   
        jsx         14 - 319            17               17   

                                                                File "ex2.json"
      jason         11 - 117            17               18   
      jiffy          2 - 174             4                5   
      jsone          3 - 119             6                8   
        jsx          7 - 62             10               11   

                                                                File "ex3.json"
      jason         28 - 91             34               37   
      jiffy          5 - 115             8                9   
      jsone          8 - 119            11               12   
        jsx         18 - 96             21               22   

                                                                File "ex4.json"
      jason        162 - 657           223              225   
      jiffy         20 - 82             23               27   
      jsone         42 - 413            54               54   
        jsx        108 - 1056          119              123   

                                                                File "ex5.json"
      jason         44 - 412            59               61   
      jiffy          9 - 59             12               13   
      jsone         12 - 213            17               17   
        jsx         25 - 184            37               34   

Clone this wiki locally