class Bench::Commands::Remove

Public Instance Methods

before(options, existing_measurements) click to toggle source
# 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