Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Benchmarking loading JSON file vs YML file #2897

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 28 additions & 9 deletions tasks/benchmark.rake
Expand Up @@ -5,15 +5,34 @@
require 'benchmark'
require 'faker'

desc 'Benchmarking every Faker generator'
task :benchmark do
all_methods = BenchmarkHelper.all_methods
count = all_methods.count

Benchmark.bmbm do |x|
x.report("Number of generators: #{count}") do
100.times do
all_methods.each { |method_name| eval(method_name) }
namespace :benchmark do
desc 'Benchmarking all methods'
task :all_methods do
all_methods = BenchmarkHelper.all_methods
count = all_methods.count

Benchmark.bmbm do |x|
x.report("Number of generators: #{count}") do
100.times do
all_methods.each { |method_name| eval(method_name) }
end
end
end
end

desc 'Comparing loading translations from YML vs. JSON'
task :compare_loading_yml_vs_json do
Benchmark.bmbm do |x|
x.report('YML') do
100.times do
YAML.load_file(File.expand_path("#{File.dirname(__FILE__)}/../lib/locales/es-MX.yml"))
end
end

x.report('JSON') do
100.times do
JSON.load_file("#{File.dirname(__FILE__)}/../test/fixtures/locales/es-MX.json")
end
end
end
end
Expand Down