Closed yosiat closed 4 years ago
Until this commit we took json strings out of db and did JSON.parse on them.
This commit changes this to:
Oj.sc_parse
Oj::StringWriter#push_json
Benchmarks:
master:
{"label":"Panko_ActiveRecord_SimpleWithJson_Posts_2300","ips":"93.59","allocs":"29919/0"} {"label":"Panko_ActiveRecord_SimpleWithJson_Posts_50","ips":"4,296.59","allocs":"669/0"}
this commit:
{"label":"Panko_ActiveRecord_SimpleWithJson_Posts_2300","ips":"146.93","allocs":"9219/0"} {"label":"Panko_ActiveRecord_SimpleWithJson_Posts_50","ips":"6,650.14","allocs":"219/0"}
less allocations and faster!
Until this commit we took json strings out of db and did JSON.parse on them.
This commit changes this to:
Oj.sc_parse
to validate that the string is valid JSONOj::StringWriter#push_json
to push the json string as is.Benchmarks:
master:
this commit:
less allocations and faster!