Class: Bench::Commands::Remove

Inherits:
Command
  • Object
show all
Defined in:
lib/bench9000/commands/remove.rb

Instance Method Summary collapse

Methods inherited from Command

#after, #benchmark_complete, #result

Instance Method Details

#before(options, existing_measurements) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/bench9000/commands/remove.rb', line 14

def before(options, existing_measurements)
  if options.flags.has_key?("--data")
    file = File.open(options.flags["--data"], "w")
    file.puts "version #{CONFIG_VERSION}"

    existing_measurements.measurements.each do |bi, measurement|
      b, i = bi

      unless options.benchmarks.map(&:name).include?(b) ||
          options.implementations.map(&:name).include?(i)
        if measurement == :failed
          file.puts JSON.generate({benchmark: b, implementation: i, failed: true})
        else
          file.puts JSON.generate({benchmark: b, implementation: i, warmup_samples: measurement.warmup_samples, samples: measurement.samples})
        end
      end
    end

    file.close
  end

  false
end