15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/bench9000/json-formatter.rb', line 15
def self.format(options, measurements)
benchmarks = options.benchmarks
implementations = options.implementations
JSON.pretty_generate({
benchmarks: benchmarks,
implementations: implementations,
measurements: benchmarks.product(implementations).map do |b, i|
measurement = measurements[b, i]
if measurement == :failed
{
benchmark: b,
implementation: i,
failed: true
}
else
{
benchmark: b,
implementation: i,
warmup_time: measurement.warmup_time,
sample_mean: measurement.sample_mean,
sample_error: measurement.sample_error,
score: measurement.score,
score_error: measurement.score_error,
warmup_samples: measurement.warmup_samples,
samples: measurement.samples
}
end
end
})
end
|