diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2014-06-14 12:58:40 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2014-06-14 12:58:40 -0700 |
commit | c10a3f55c025e21303e642e64bc3654607554c02 (patch) | |
tree | 861c23e0496199953d28540f2a83cae3237655d2 | |
parent | e0c7dcbe986700cccd42d954a29298b5dc34b28e (diff) | |
download | ffi-yajl-c10a3f55c025e21303e642e64bc3654607554c02.tar.gz |
add Oj.load
-rwxr-xr-x | bin/ffi-yajl-bench | 1 | ||||
-rw-r--r-- | lib/ffi_yajl/benchmark/encode.rb | 14 | ||||
-rw-r--r-- | lib/ffi_yajl/benchmark/parse.rb | 13 |
3 files changed, 21 insertions, 7 deletions
diff --git a/bin/ffi-yajl-bench b/bin/ffi-yajl-bench index 3502311..5b3bf85 100755 --- a/bin/ffi-yajl-bench +++ b/bin/ffi-yajl-bench @@ -33,4 +33,5 @@ if opts[:profile] FFI_Yajl::Benchmark::ParseProfileRubyProf.new().run() else FFI_Yajl::Benchmark::Parse.new().run() + FFI_Yajl::Benchmark::Encode.new().run() end diff --git a/lib/ffi_yajl/benchmark/encode.rb b/lib/ffi_yajl/benchmark/encode.rb index 65c6435..e0fb390 100644 --- a/lib/ffi_yajl/benchmark/encode.rb +++ b/lib/ffi_yajl/benchmark/encode.rb @@ -120,13 +120,13 @@ module FFI_Yajl } end end - if defined?(ActiveSupport::JSON) - x.report("ActiveSupport::JSON.encode") { - times.times { - ActiveSupport::JSON.encode(hash) - } - } - end +# if defined?(ActiveSupport::JSON) +# x.report("ActiveSupport::JSON.encode") { +# times.times { +# ActiveSupport::JSON.encode(hash) +# } +# } +# end } end end diff --git a/lib/ffi_yajl/benchmark/parse.rb b/lib/ffi_yajl/benchmark/parse.rb index e091343..02ad740 100644 --- a/lib/ffi_yajl/benchmark/parse.rb +++ b/lib/ffi_yajl/benchmark/parse.rb @@ -28,6 +28,10 @@ begin require 'active_support' rescue LoadError end +begin + require 'oj' +rescue LoadError +end class FFI_Yajl::Benchmark::Parse @@ -79,6 +83,15 @@ class FFI_Yajl::Benchmark::Parse } } end + if defined?(Oj) + x.report { + puts "Oj.load" + times.times { + json.rewind + Oj.load(json.read) + } + } + end if defined?(JSON) x.report { puts "JSON.parse" |