require'json' p JSON.generate "abc" p JSON.generate 123 p JSON.generate true p JSON.generate nil p JSON.generate [2,3,4] p JSON.generate({name:"junmajinlong", age:23}) require'set' p JSON.generate(Set.new([1,23,44]))
---------------------------------- load file ----------------------------------- user system total real JSON.load: 1.591831 0.058021 1.649852 ( 1.738119) Oj.load_file: 1.350385 0.057684 1.408069 ( 2.434268) <-慢 FastJsonparser.load: 0.653968 0.103258 0.757226 ( 0.848913) <-快
------------------------ load file with symbolize_keys ------------------------- user system total real JSON.load: 1.212617 0.039052 1.251669 ( 1.349545) Oj.load_file: 1.432059 0.098950 1.531009 ( 2.679610) <-慢 FastJsonparser.load: 0.695538 0.008384 0.703922 ( 0.797081) <-快
---------------------------------- parse str ----------------------------------- user system total real JSON.parse: 1.343596 0.000000 1.343596 ( 1.350368) Oj.load: 1.133612 0.000000 1.133612 ( 1.140939) FastJsonparser.parse: 0.701701 0.012340 0.714041 ( 0.720296) <-快
------------------------ parse str with symbolize_keys ------------------------- user system total real JSON.parse: 1.250775 0.000000 1.250775 ( 1.258796) Oj.load: 1.131296 0.000000 1.131296 ( 1.138020) FastJsonparser.parse: 0.697433 0.015962 0.713395 ( 0.719439) <-快
------------------------------- dump JSON to str ------------------------------- user system total real JSON.dump: 1.374611 0.028454 1.403065 ( 1.403081) Oj.dump: 1.025049 0.040184 1.065233 ( 1.065246) <-快
------------------------------ dump JSON to file ------------------------------- user system total real JSON.dump: 1.234362 0.040246 1.274608 ( 1.369214) Oj.to_file: 1.168707 0.000000 1.168707 ( 1.270957)
---------------------------------- load file ----------------------------------- user system total real JSON.load: 1.362151 0.083610 1.445761 ( 1.569754) Oj.load_file: 1.343601 0.182046 1.525647 ( 2.684472) <-慢 FastJsonparser.load: 2.634435 0.052734 2.687169 ( 2.776105) <-慢
------------------------ load file with symbolize_keys ------------------------- user system total real JSON.load: 1.287954 0.018572 1.306526 ( 1.409770) Oj.load_file: 1.478750 0.043847 1.522597 ( 2.668882) <-慢 FastJsonparser.load: 2.717857 0.006164 2.724021 ( 2.822728) <-慢
---------------------------------- parse str ----------------------------------- user system total real JSON.parse: 1.242225 0.008661 1.250886 ( 1.304554) Oj.load: 1.097922 0.000000 1.097922 ( 1.110031) FastJsonparser.parse: 2.602679 0.017232 2.619911 ( 2.634604) <-慢
------------------------ parse str with symbolize_keys ------------------------- user system total real JSON.parse: 1.368262 0.000000 1.368262 ( 1.380730) Oj.load: 1.332349 0.000000 1.332349 ( 1.346331) FastJsonparser.parse: 2.706804 0.007238 2.714042 ( 2.726935) <-慢
------------------------------- dump JSON to str ------------------------------- user system total real JSON.dump: 1.724653 0.009250 1.733903 ( 1.733912) Oj.dump: 1.298235 0.030041 1.328276 ( 1.328279) <-快
------------------------------ dump JSON to file ------------------------------- user system total real JSON.dump: 1.765664 0.040595 1.806259 ( 1.905785) Oj.to_file: 1.228744 0.020309 1.249053 ( 1.349684) <-快 =end