From c10a3f55c025e21303e642e64bc3654607554c02 Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Sat, 14 Jun 2014 12:58:40 -0700 Subject: add Oj.load --- bin/ffi-yajl-bench | 1 + lib/ffi_yajl/benchmark/encode.rb | 14 +++++++------- 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" -- cgit v1.2.1