summaryrefslogtreecommitdiff
path: root/lib/ffi_yajl/benchmark/parse_profile.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ffi_yajl/benchmark/parse_profile.rb')
-rw-r--r--lib/ffi_yajl/benchmark/parse_profile.rb20
1 files changed, 9 insertions, 11 deletions
diff --git a/lib/ffi_yajl/benchmark/parse_profile.rb b/lib/ffi_yajl/benchmark/parse_profile.rb
index 9e53729..6ef00ac 100644
--- a/lib/ffi_yajl/benchmark/parse_profile.rb
+++ b/lib/ffi_yajl/benchmark/parse_profile.rb
@@ -15,20 +15,18 @@ module FFI_Yajl
class Benchmark
class ParseProfile
def run
- if defined?(PerfTools)
- filename = File.expand_path(File.join(File.dirname(__FILE__), "subjects", "ohai.json"))
- json = File.new(filename, 'r').read
+ return if defined?(PerfTools)
- times = 1000
- puts "Starting profiling encoding #{filename} #{times} times\n\n"
+ filename = File.expand_path(File.join(File.dirname(__FILE__), "subjects", "ohai.json"))
+ json = File.new(filename, 'r').read
- PerfTools::CpuProfiler.start("/tmp/ffi_yajl_encode_profile.out") do
- times.times {
- FFI_Yajl::Parser.parse(json)
- }
- end
- system("pprof.rb --text /tmp/ffi_yajl_encode_profile.out")
+ times = 1000
+ puts "Starting profiling encoding #{filename} #{times} times\n\n"
+
+ PerfTools::CpuProfiler.start("/tmp/ffi_yajl_encode_profile.out") do
+ times.times { FFI_Yajl::Parser.parse(json) }
end
+ system("pprof.rb --text /tmp/ffi_yajl_encode_profile.out")
end
end
end