Last active
March 8, 2016 07:37
-
-
Save key-amb/2b7bf0dcd6c6de23eb88 to your computer and use it in GitHub Desktop.
jm/toml vs. eMancu/toml-rb vs. fbernier/tomlrb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'toml' | |
require 'tomlrb' | |
require 'benchmark' | |
toml = <<-EOS | |
title = "sample" | |
[params] | |
id = 101 | |
name = "taro" | |
[foo.bar] | |
attr1 = "aaa" | |
attr2 = "bbb" | |
attr3 = "ccc" | |
EOS | |
n = 100 | |
Benchmark.bm(7) do |x| | |
# jm/toml and eMancu/toml-rb can't load together because they use same namespace | |
#x.report('toml') { (1..n).each {|i| TOML::Parser.new(toml).parsed } } | |
x.report('toml-rb') { (1..n).each {|i| TOML.parse(toml) } } | |
x.report('tomlrb') { (1..n).each {|i| Tomlrb.parse(toml) } } | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// toml-rb vs. tomlrb | |
% ruby bench-toml.rb | |
user system total real | |
toml-rb 0.190000 0.010000 0.200000 ( 0.205336) | |
tomlrb 0.020000 0.000000 0.020000 ( 0.020378) | |
// toml vs. tomlrb | |
% ruby tmp/test-toml.rb | |
user system total real | |
toml 0.400000 0.000000 0.400000 ( 0.413219) | |
tomlrb 0.020000 0.000000 0.020000 ( 0.025820) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment