æåã« (tl;drãªãã¦è¨ããªãã)
çµè«ããããã¨JSONã®æ¹ã10åéãã£ãã
æ¦è¦
åºæ¬çã«ãã¹ã¿ãã¼ã¿ã¯YAMLã§ç®¡çããããã«ãã¦ããã®ã ããã©ãªããJSONã§ãã«ãªã¯è²°ã£ã¦ã¤ã©ã¤ã©ããªãããã³ãã¨ã£ã¦è¨¼æ ã«ãããã¨ãããäºæ³ã¨éã ã£ããä¸å®ä»¥ä¸ã®ãµã¤ãºã«ãªãã¨YAMLãé転ãããã®ã ã¨æã£ã¦ããã
ãã³ãçµæ
以ä¸ã®ãããªãã¡ã¤ã«ãèªã¿è¾¼ãã
â ls -lh story.yml story.json 2.1.2 11:30:20 -rw-r--r-- 1 tomohiro staff 13K 7 17 11:15 hoge.json -rw-r--r-- 1 tomohiro staff 11K 7 17 11:15 hoge.yml
çµæã¯ä»¥ä¸ã®ããã«ãªã£ããJSONã®æ¹ã10åãããéããå§åçéãã¦ãªãã¨ãè¨ããªãã
Rehearsal ---------------------------------------- JSON 0.040000 0.000000 0.040000 ( 0.038241) YAML 0.380000 0.000000 0.380000 ( 0.382941) ------------------------------- total: 0.420000sec user system total real JSON 0.030000 0.010000 0.040000 ( 0.032264) YAML 0.370000 0.000000 0.370000 ( 0.368527)
ãã¡ã¤ã«ãµã¤ãºãå¢ããã¦1MB以ä¸ã®ãã¡ã¤ã«ã§è©¦ããã¨ãã以ä¸ã®ããã«ãªã£ãã ããYAMLãé ããªã£ã¦ãããå ¨ç¶èªèã¨éã£ã¦èª¿ã¹ã¦è¯ãã£ãã¨ããæãã
Rehearsal ---------------------------------------- JSON 4.270000 0.200000 4.470000 ( 4.485176) YAML 44.640000 0.310000 44.950000 ( 44.982451) ------------------------------ total: 49.420000sec user system total real JSON 4.240000 0.300000 4.540000 ( 4.537489) YAML 43.530000 0.340000 43.870000 ( 43.896849)
以ä¸ã®ã³ã¼ãã§ãã³ãåã£ãã
require "benchmark" require "oj" require "psych" Benchmark.bmbm do |x| x.report("JSON") { 100.times { Oj.load(File.open("hoge.json")) } } x.report("YAML") { 100.times { Psych.load(File.open("hoge.yml")) } } end
oj ã¯ãªããéãã㤠( see also: https://github.com/ohler55/oj )