Closed sile closed 3 years ago
This PR improves the encoding speed of unescaped strings (e.g., alphabets, numbers, some symbols) in JSON texts.
master
$ git clone https://github.com/devinus/poison $ rebar3 shell > A = jsone:decode(element(2, file:read_file("poison/bench/data/blockchain.json"))). > timer:tc(fun () -> lists:foreach(fun (_) -> jsone:encode(A) end, lists:seq(1, 1000)) end). {636792,ok} % 0.636s > B = jsone:decode(element(2, file:read_file("poison/bench/data/issue-90.json"))). > timer:tc(fun () -> lists:foreach(fun (_) -> jsone:encode(B) end, lists:seq(1, 10)) end). {5247205,ok} % 5.247s
$ git clone https://github.com/devinus/poison $ rebar3 shell > A = jsone:decode(element(2, file:read_file("poison/bench/data/blockchain.json"))). > timer:tc(fun () -> lists:foreach(fun (_) -> jsone:encode(A) end, lists:seq(1, 1000)) end). {265974,ok} % 0.265s > B = jsone:decode(element(2, file:read_file("poison/bench/data/issue-90.json"))). > timer:tc(fun () -> lists:foreach(fun (_) -> jsone:encode(B) end, lists:seq(1, 10)) end). {985962,ok} % 0.985s
This PR improves the encoding speed of unescaped strings (e.g., alphabets, numbers, some symbols) in JSON texts.
Example benchmarks
Before (the
master
branch)After (this PR)