class Phantomherd::Runner

Attributes

casper_script[R]
concurrency[R]
results[RW]
sample_count[R]

Public Class Methods

new(options) click to toggle source
# File lib/phantomherd/runner.rb, line 10
def initialize(options)
  @sample_count = options[:sample_count]
  @concurrency = options[:concurrency]
  @casper_script = options[:casper_script]
  @results = []
end

Public Instance Methods

run() click to toggle source
# File lib/phantomherd/runner.rb, line 17
def run
  requests = (1..sample_count.to_i).to_a
  EM.synchrony do
    EM::Synchrony::FiberIterator.new(requests, concurrency).each do |request|
      stime = Time.now
      out, status = EM::Synchrony.system("casperjs --ignore-ssl-errors=yes #{casper_script}")
      print "."
      @results << Time.now - stime
    end
    print "\n"
    EventMachine.stop
  end
  print_results
end

Private Instance Methods

print_results() click to toggle source