summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/ffi-yajl-bench1
-rw-r--r--lib/ffi_yajl/benchmark/encode.rb14
-rw-r--r--lib/ffi_yajl/benchmark/parse.rb13
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"