summaryrefslogtreecommitdiff
path: root/lib/ffi_yajl/benchmark
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ffi_yajl/benchmark')
-rw-r--r--lib/ffi_yajl/benchmark/encode.rb16
-rw-r--r--lib/ffi_yajl/benchmark/encode_json_and_marshal.rb18
-rw-r--r--lib/ffi_yajl/benchmark/encode_json_and_yaml.rb22
-rw-r--r--lib/ffi_yajl/benchmark/encode_profile.rb10
-rw-r--r--lib/ffi_yajl/benchmark/http.rb24
-rw-r--r--lib/ffi_yajl/benchmark/parse.rb20
-rw-r--r--lib/ffi_yajl/benchmark/parse_json_and_marshal.rb22
-rw-r--r--lib/ffi_yajl/benchmark/parse_json_and_yaml.rb24
-rw-r--r--lib/ffi_yajl/benchmark/parse_profile.rb10
-rw-r--r--lib/ffi_yajl/benchmark/parse_profile_ruby_prof.rb8
-rw-r--r--lib/ffi_yajl/benchmark/parse_stream.rb20
11 files changed, 97 insertions, 97 deletions
diff --git a/lib/ffi_yajl/benchmark/encode.rb b/lib/ffi_yajl/benchmark/encode.rb
index fc03c06..17e12cc 100644
--- a/lib/ffi_yajl/benchmark/encode.rb
+++ b/lib/ffi_yajl/benchmark/encode.rb
@@ -1,26 +1,26 @@
# Portions Originally Copyright (c) 2008-2011 Brian Lopez - http://github.com/brianmario
# See MIT-LICENSE
-require 'rubygems'
-require 'benchmark'
-require 'stringio'
+require "rubygems"
+require "benchmark"
+require "stringio"
if !defined?(RUBY_ENGINE) || RUBY_ENGINE !~ /jruby/
begin
- require 'yajl'
+ require "yajl"
rescue LoadError
puts "INFO: yajl-ruby not installed"
end
else
puts "INFO: skipping yajl-ruby on jruby"
end
-require 'ffi_yajl'
+require "ffi_yajl"
begin
- require 'json'
+ require "json"
rescue LoadError
puts "INFO: json gem not installed"
end
begin
- require 'oj'
+ require "oj"
rescue LoadError
puts "INFO: oj gem not installed"
end
@@ -31,7 +31,7 @@ module FFI_Yajl
def run
# filename = ARGV[0] || 'benchmark/subjects/ohai.json'
filename = File.expand_path(File.join(File.dirname(__FILE__), "subjects", "ohai.json"))
- hash = File.open(filename, 'rb') { |f| FFI_Yajl::Parser.parse(f.read) }
+ hash = File.open(filename, "rb") { |f| FFI_Yajl::Parser.parse(f.read) }
times = ARGV[1] ? ARGV[1].to_i : 1000
puts "Starting benchmark encoding #{filename} #{times} times\n\n"
diff --git a/lib/ffi_yajl/benchmark/encode_json_and_marshal.rb b/lib/ffi_yajl/benchmark/encode_json_and_marshal.rb
index e9d19bc..4269056 100644
--- a/lib/ffi_yajl/benchmark/encode_json_and_marshal.rb
+++ b/lib/ffi_yajl/benchmark/encode_json_and_marshal.rb
@@ -1,18 +1,18 @@
-$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/..')
-$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
+$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + "/..")
+$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + "/../lib")
-require 'rubygems'
-require 'benchmark'
-require 'yajl'
-require 'stringio'
+require "rubygems"
+require "benchmark"
+require "yajl"
+require "stringio"
begin
- require 'json'
+ require "json"
rescue LoadError
end
times = ARGV[0] ? ARGV[0].to_i : 1000
-filename = 'benchmark/subjects/ohai.json'
-json = File.new(filename, 'r')
+filename = "benchmark/subjects/ohai.json"
+json = File.new(filename, "r")
hash = Yajl::Parser.new.parse(json)
json.close
diff --git a/lib/ffi_yajl/benchmark/encode_json_and_yaml.rb b/lib/ffi_yajl/benchmark/encode_json_and_yaml.rb
index 33dbbb2..72310c1 100644
--- a/lib/ffi_yajl/benchmark/encode_json_and_yaml.rb
+++ b/lib/ffi_yajl/benchmark/encode_json_and_yaml.rb
@@ -1,18 +1,18 @@
-$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/..')
-$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
+$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + "/..")
+$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + "/../lib")
-require 'rubygems'
-require 'benchmark'
-require 'yajl'
+require "rubygems"
+require "benchmark"
+require "yajl"
begin
- require 'json'
+ require "json"
rescue LoadError
end
-require 'yaml'
+require "yaml"
# JSON Section
-filename = 'benchmark/subjects/ohai.json'
-json = File.new(filename, 'r')
+filename = "benchmark/subjects/ohai.json"
+json = File.new(filename, "r")
hash = Yajl::Parser.new.parse(json)
json.close
@@ -33,8 +33,8 @@ Benchmark.bmbm do |x|
end
# YAML Section
-filename = 'benchmark/subjects/ohai.yml'
-yml = File.new(filename, 'r')
+filename = "benchmark/subjects/ohai.yml"
+yml = File.new(filename, "r")
data = YAML.load_stream(yml)
yml.close
diff --git a/lib/ffi_yajl/benchmark/encode_profile.rb b/lib/ffi_yajl/benchmark/encode_profile.rb
index 36b92c7..468f88b 100644
--- a/lib/ffi_yajl/benchmark/encode_profile.rb
+++ b/lib/ffi_yajl/benchmark/encode_profile.rb
@@ -1,15 +1,15 @@
# Portions Originally Copyright (c) 2008-2011 Brian Lopez - http://github.com/brianmario
# See MIT-LICENSE
-require 'rubygems'
-require 'ffi_yajl'
+require "rubygems"
+require "ffi_yajl"
begin
- require 'perftools'
+ require "perftools"
rescue LoadError
puts "INFO: perftools.rb gem not installed"
end
-ENV['CPUPROFILE_FREQUENCY'] = "4000"
+ENV["CPUPROFILE_FREQUENCY"] = "4000"
module FFI_Yajl
class Benchmark
@@ -18,7 +18,7 @@ module FFI_Yajl
return unless defined?(PerfTools)
filename = File.expand_path(File.join(File.dirname(__FILE__), "subjects", "ohai.json"))
- hash = File.open(filename, 'rb') { |f| FFI_Yajl::Parser.parse(f.read) }
+ hash = File.open(filename, "rb") { |f| FFI_Yajl::Parser.parse(f.read) }
times = 1000
puts "Starting profiling encoding #{filename} #{times} times\n\n"
diff --git a/lib/ffi_yajl/benchmark/http.rb b/lib/ffi_yajl/benchmark/http.rb
index b94a46c..0b19387 100644
--- a/lib/ffi_yajl/benchmark/http.rb
+++ b/lib/ffi_yajl/benchmark/http.rb
@@ -1,17 +1,17 @@
-$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/..')
-$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
+$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + "/..")
+$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + "/../lib")
-require 'rubygems'
-require 'benchmark'
-require 'yajl/http_stream'
-require 'yajl/gzip'
-require 'yajl/deflate'
-require 'yajl/bzip2' unless defined?(Bzip2)
-require 'json'
-require 'uri'
-require 'net/http'
+require "rubygems"
+require "benchmark"
+require "yajl/http_stream"
+require "yajl/gzip"
+require "yajl/deflate"
+require "yajl/bzip2" unless defined?(Bzip2)
+require "json"
+require "uri"
+require "net/http"
-uri = URI.parse('http://search.twitter.com/search.json?q=github')
+uri = URI.parse("http://search.twitter.com/search.json?q=github")
# uri = URI.parse('http://localhost/yajl-ruby.git/benchmark/subjects/contacts.json')
times = ARGV[0] ? ARGV[0].to_i : 1
diff --git a/lib/ffi_yajl/benchmark/parse.rb b/lib/ffi_yajl/benchmark/parse.rb
index 6aacc94..f7ab8b1 100644
--- a/lib/ffi_yajl/benchmark/parse.rb
+++ b/lib/ffi_yajl/benchmark/parse.rb
@@ -1,10 +1,10 @@
-require 'rubygems'
-require 'benchmark'
-require 'yajl'
-require 'ffi_yajl'
+require "rubygems"
+require "benchmark"
+require "yajl"
+require "ffi_yajl"
if !defined?(RUBY_ENGINE) || RUBY_ENGINE !~ /jruby/
begin
- require 'yajl'
+ require "yajl"
rescue LoadError
puts "INFO: yajl-ruby not installed"
end
@@ -12,11 +12,11 @@ else
puts "INFO: skipping yajl-ruby on jruby"
end
begin
- require 'json'
+ require "json"
rescue LoadError
end
begin
- require 'oj'
+ require "oj"
rescue LoadError
end
@@ -25,7 +25,7 @@ module FFI_Yajl
class Parse
def run
filename = File.expand_path(File.join(File.dirname(__FILE__), "subjects", "item.json"))
- json = File.new(filename, 'r')
+ json = File.new(filename, "r")
json_str = json.read
times = ARGV[1] ? ARGV[1].to_i : 10_000
@@ -49,7 +49,7 @@ module FFI_Yajl
times.times { Yajl::Parser.parse(json_str) }
end
io_parser = Yajl::Parser.new
- io_parser.on_parse_complete = ->(obj) {} if times > 1
+ io_parser.on_parse_complete = ->(_obj) {} if times > 1
x.report do
puts "Yajl::Parser#parse (from an IO)"
times.times do
@@ -58,7 +58,7 @@ module FFI_Yajl
end
end
string_parser = Yajl::Parser.new
- string_parser.on_parse_complete = ->(obj) {} if times > 1
+ string_parser.on_parse_complete = ->(_obj) {} if times > 1
x.report do
puts "Yajl::Parser#parse (from a String)"
times.times do
diff --git a/lib/ffi_yajl/benchmark/parse_json_and_marshal.rb b/lib/ffi_yajl/benchmark/parse_json_and_marshal.rb
index cd07d46..194c18b 100644
--- a/lib/ffi_yajl/benchmark/parse_json_and_marshal.rb
+++ b/lib/ffi_yajl/benchmark/parse_json_and_marshal.rb
@@ -1,19 +1,19 @@
-$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/..')
-$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
+$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + "/..")
+$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + "/../lib")
-require 'rubygems'
-require 'benchmark'
-require 'yajl'
+require "rubygems"
+require "benchmark"
+require "yajl"
begin
- require 'json'
+ require "json"
rescue LoadError
end
# JSON section
-filename = 'benchmark/subjects/ohai.json'
-marshal_filename = 'benchmark/subjects/ohai.marshal_dump'
-json = File.new(filename, 'r')
-marshal_file = File.new(marshal_filename, 'r')
+filename = "benchmark/subjects/ohai.json"
+marshal_filename = "benchmark/subjects/ohai.marshal_dump"
+json = File.new(filename, "r")
+marshal_file = File.new(marshal_filename, "r")
hash = {}
@@ -23,7 +23,7 @@ Benchmark.bmbm do |x|
x.report do
puts "Yajl::Parser#parse"
yajl = Yajl::Parser.new
- yajl.on_parse_complete = ->(obj) {} if times > 1
+ yajl.on_parse_complete = ->(_obj) {} if times > 1
times.times do
json.rewind
hash = yajl.parse(json)
diff --git a/lib/ffi_yajl/benchmark/parse_json_and_yaml.rb b/lib/ffi_yajl/benchmark/parse_json_and_yaml.rb
index 6e479ce..d73d0bd 100644
--- a/lib/ffi_yajl/benchmark/parse_json_and_yaml.rb
+++ b/lib/ffi_yajl/benchmark/parse_json_and_yaml.rb
@@ -1,24 +1,24 @@
-$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/..')
-$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
+$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + "/..")
+$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + "/../lib")
-require 'rubygems'
-require 'benchmark'
-require 'yajl'
+require "rubygems"
+require "benchmark"
+require "yajl"
begin
- require 'json'
+ require "json"
rescue LoadError
end
-require 'yaml'
+require "yaml"
# JSON section
-filename = 'benchmark/subjects/ohai.json'
-json = File.new(filename, 'r')
+filename = "benchmark/subjects/ohai.json"
+json = File.new(filename, "r")
times = ARGV[0] ? ARGV[0].to_i : 1000
puts "Starting benchmark parsing #{File.size(filename)} bytes of JSON data #{times} times\n\n"
Benchmark.bmbm do |x|
parser = Yajl::Parser.new
- parser.on_parse_complete = ->(obj) {} if times > 1
+ parser.on_parse_complete = ->(_obj) {} if times > 1
x.report do
puts "Yajl::Parser#parse"
times.times do
@@ -39,8 +39,8 @@ end
json.close
# YAML section
-filename = 'benchmark/subjects/ohai.yml'
-yaml = File.new(filename, 'r')
+filename = "benchmark/subjects/ohai.yml"
+yaml = File.new(filename, "r")
puts "Starting benchmark parsing #{File.size(filename)} bytes of YAML data #{times} times\n\n"
Benchmark.bmbm do |x|
diff --git a/lib/ffi_yajl/benchmark/parse_profile.rb b/lib/ffi_yajl/benchmark/parse_profile.rb
index 6ef00ac..4b396b4 100644
--- a/lib/ffi_yajl/benchmark/parse_profile.rb
+++ b/lib/ffi_yajl/benchmark/parse_profile.rb
@@ -1,15 +1,15 @@
# Portions Originally Copyright (c) 2008-2011 Brian Lopez - http://github.com/brianmario
# See MIT-LICENSE
-require 'rubygems'
-require 'ffi_yajl'
+require "rubygems"
+require "ffi_yajl"
begin
- require 'perftools'
+ require "perftools"
rescue LoadError
puts "INFO: perftools.rb gem not installed"
end
-ENV['CPUPROFILE_FREQUENCY'] = "4000"
+ENV["CPUPROFILE_FREQUENCY"] = "4000"
module FFI_Yajl
class Benchmark
@@ -18,7 +18,7 @@ module FFI_Yajl
return if defined?(PerfTools)
filename = File.expand_path(File.join(File.dirname(__FILE__), "subjects", "ohai.json"))
- json = File.new(filename, 'r').read
+ json = File.new(filename, "r").read
times = 1000
puts "Starting profiling encoding #{filename} #{times} times\n\n"
diff --git a/lib/ffi_yajl/benchmark/parse_profile_ruby_prof.rb b/lib/ffi_yajl/benchmark/parse_profile_ruby_prof.rb
index 51696c5..2c4021a 100644
--- a/lib/ffi_yajl/benchmark/parse_profile_ruby_prof.rb
+++ b/lib/ffi_yajl/benchmark/parse_profile_ruby_prof.rb
@@ -1,15 +1,15 @@
# Portions Originally Copyright (c) 2008-2011 Brian Lopez - http://github.com/brianmario
# See MIT-LICENSE
-require 'rubygems'
-require 'ffi_yajl'
+require "rubygems"
+require "ffi_yajl"
module FFI_Yajl
class Benchmark
class ParseProfileRubyProf
def run
begin
- require 'ruby-prof'
+ require "ruby-prof"
rescue LoadError
puts "INFO: perftools.rb gem not installed"
end
@@ -17,7 +17,7 @@ module FFI_Yajl
return if defined?(RubyProf)
filename = File.expand_path(File.join(File.dirname(__FILE__), "subjects", "ohai.json"))
- json = File.new(filename, 'r').read
+ json = File.new(filename, "r").read
times = 1000
puts "Starting profiling encoding #{filename} #{times} times\n\n"
diff --git a/lib/ffi_yajl/benchmark/parse_stream.rb b/lib/ffi_yajl/benchmark/parse_stream.rb
index 679eb92..d689a3d 100644
--- a/lib/ffi_yajl/benchmark/parse_stream.rb
+++ b/lib/ffi_yajl/benchmark/parse_stream.rb
@@ -1,26 +1,26 @@
-$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/..')
-$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
+$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + "/..")
+$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + "/../lib")
-require 'rubygems'
-require 'benchmark'
-require 'yajl'
+require "rubygems"
+require "benchmark"
+require "yajl"
begin
- require 'json'
+ require "json"
rescue LoadError
end
begin
- require 'active_support'
+ require "active_support"
rescue LoadError
end
-filename = 'benchmark/subjects/twitter_stream.json'
-json = File.new(filename, 'r')
+filename = "benchmark/subjects/twitter_stream.json"
+json = File.new(filename, "r")
times = ARGV[0] ? ARGV[0].to_i : 100
puts "Starting benchmark parsing JSON stream (#{File.size(filename)} bytes of JSON data with 430 JSON separate strings) #{times} times\n\n"
Benchmark.bmbm do |x|
parser = Yajl::Parser.new
- parser.on_parse_complete = ->(obj) {}
+ parser.on_parse_complete = ->(_obj) {}
x.report do
puts "Yajl::Parser#parse"
times.times do