class Grntest::Reporters::BenchmarkJSONReporter
Public Instance Methods
Source
# File lib/grntest/reporters/benchmark-json-reporter.rb, line 117 def on_finish(result) puts puts(<<-JSON) ] } JSON end
Source
# File lib/grntest/reporters/benchmark-json-reporter.rb, line 24 def on_start(result) puts(<<-JSON) { "context": { "date": #{Time.now.iso8601.to_json}, "host_name": #{Socket.gethostname.to_json}, "executable": #{@tester.testee.to_json}, "num_cpus": #{Etc.nprocessors}, JSON cpu_cycles_per_second = detect_cpu_cycles_per_second if cpu_cycles_per_second puts(<<-JSON) "mhz_per_cpu": #{cpu_cycles_per_second / 1_000_000.0}, JSON end print(<<-JSON.chomp) "caches": [] }, "benchmarks": [ JSON @first_benchmark = true end
Source
# File lib/grntest/reporters/benchmark-json-reporter.rb, line 111 def on_suite_finish(worker) end
Source
# File lib/grntest/reporters/benchmark-json-reporter.rb, line 50 def on_suite_start(worker) end
Source
# File lib/grntest/reporters/benchmark-json-reporter.rb, line 59 def on_test_failure(worker, result) output, @output = @output, $stderr begin report_failure(result) ensure @output = output end end
Source
# File lib/grntest/reporters/benchmark-json-reporter.rb, line 87 def on_test_finish(worker, result) return if result.benchmarks.empty? result.benchmarks.each do |benchmark| print(",") unless @first_benchmark @first_benchmark = false puts name = "#{@tester.interface}: " + "#{@tester.input_type}|#{@tester.output_type}: " + "#{worker.suite_name}/#{result.test_name}" print(<<-JSON.chomp) { "name": #{name.to_json}, "run_name": #{benchmark.name.to_json}, "run_type": "iteration", "iterations": #{benchmark.n_iterations}, "real_time": #{benchmark.real_elapsed_time}, "cpu_time": #{benchmark.cpu_elapsed_time}, "time_unit": "s", "items_per_second": #{benchmark.items_per_second} } JSON end end
Source
# File lib/grntest/reporters/benchmark-json-reporter.rb, line 68 def on_test_leak(worker, result) output, @output = @output, $stderr begin puts report_test(worker, result) ensure @output = output end end
Source
# File lib/grntest/reporters/benchmark-json-reporter.rb, line 84 def on_test_no_check(worker, result) end
Source
# File lib/grntest/reporters/benchmark-json-reporter.rb, line 78 def on_test_omission(worker, result) end
Source
# File lib/grntest/reporters/benchmark-json-reporter.rb, line 81 def on_test_omission_suppressed(worker, result) end
Source
# File lib/grntest/reporters/benchmark-json-reporter.rb, line 53 def on_test_start(worker) end
Source
# File lib/grntest/reporters/benchmark-json-reporter.rb, line 56 def on_test_success(worker, result) end
Source
# File lib/grntest/reporters/benchmark-json-reporter.rb, line 114 def on_worker_finish(worker) end
Source
# File lib/grntest/reporters/benchmark-json-reporter.rb, line 47 def on_worker_start(worker) end
Private Instance Methods
Source
# File lib/grntest/reporters/benchmark-json-reporter.rb, line 126 def detect_cpu_cycles_per_second if File.exist?("/proc/cpuinfo") File.open("/proc/cpuinfo") do |cpuinfo| cpuinfo.each_line do |line| case line when /\Acpu MHz\s+: ([\d.]+)/ return Float($1) end end end end nil end