diff --git a/lib/grntest/reporters/benchmark-json-reporter.rb b/lib/grntest/reporters/benchmark-json-reporter.rb index 92525fe..17ecb15 100644 --- a/lib/grntest/reporters/benchmark-json-reporter.rb +++ b/lib/grntest/reporters/benchmark-json-reporter.rb @@ -21,10 +21,6 @@ module Grntest module Reporters class BenchmarkJSONReporter < BaseReporter - def initialize(tester) - super - end - def on_start(result) puts(<<-JSON) { @@ -40,11 +36,12 @@ def on_start(result) "mhz_per_cpu": #{cpu_cycles_per_second / 1_000_000.0}, JSON end - puts(<<-JSON) + print(<<-JSON.chomp) "caches": [] }, "benchmarks": [ JSON + @first_benchmark = true end def on_worker_start(worker) @@ -79,6 +76,8 @@ def on_test_no_check(worker, result) def on_test_finish(worker, result) return if result.benchmarks.empty? + print(",") unless @first_benchmark + puts benchmarks = result.benchmarks.collect do |benchmark| name = "#{worker.suite_name}/#{result.test_name}" <<-JSON.chomp @@ -94,7 +93,8 @@ def on_test_finish(worker, result) } JSON end - puts(benchmarks.join(",\n")) + print(benchmarks.join(",\n")) + @first_benchmark = false end def on_suite_finish(worker) @@ -104,6 +104,7 @@ def on_worker_finish(worker) end def on_finish(result) + puts puts(<<-JSON) ] }