class Bmrace::Command

Public Class Methods

new(commands) click to toggle source
# File lib/bmrace/command.rb, line 9
def initialize(commands)
  @commands = commands
end
ready(*arguments) click to toggle source
# File lib/bmrace/command.rb, line 4
def ready(*arguments)
  new(arguments)
end

Public Instance Methods

go!() click to toggle source
# File lib/bmrace/command.rb, line 13
def go!
  threads = {}
  results = {}

  @commands.each do |cmd|
    threads[cmd] = Thread.new do
      start_time = Time.now
      `#{cmd}`
      end_time = Time.now
      results[cmd] = end_time - start_time
    end
  end

  threads.each do |cmd, thread|
    thread.join
  end

  results.each do |cmd, time|
    puts "#{cmd}: #{time}"
  end
end