Sha256: b710d7ca24d14ef96b84cffeefec56fc77e28af74b1d56bc15696a3f7136880a

Contents?: true

Size: 1.27 KB

Versions: 5

Compression:

Stored size: 1.27 KB

Contents

require_relative "./helpers"

describe BigBench::Benchmark::Looper do
  
  before(:each) do
    @benchmark = BigBench::Benchmark::Benchmark.new("a test benchmark", "http://localhost:3001", {}) do
      get "/"
      get "/logout"
    end
    @benchmark.start = Time.now
  end
  
  it "should get the next fragment" do
    looper = BigBench::Benchmark::Looper.new(@benchmark)
    looper.next_fragment.path.should == "/"
    looper.next_fragment.path.should == "/logout"
    looper.next_fragment.path.should == "/"
    looper.next_fragment.path.should == "/logout"
    looper.next_fragment.path.should == "/"
    looper.next_fragment.path.should == "/logout"
  end
  
  it "should do nothing if benchmark is not running" do
    looper = BigBench::Benchmark::Looper.new(@benchmark)
    looper.loop!
    
    looper.loops.should == 0
  end
  
  
  it "should loop through the fragments as long as the benchmark is running" do
    looper = BigBench::Benchmark::Looper.new(@benchmark)
    
    EventMachine.run {

      timer = Thread.new{ sleep(5); @benchmark.is_running = false; EventMachine.stop }
      @benchmark.is_running = true
      @benchmark.start = Time.now
      
      looper.loop!
    }
    
    looper.loops.should > 1000
    @benchmark.tracker.trackings.size.should == looper.loops
  end
  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
bigbench-0.0.6 spec/looper_spec.rb
bigbench-0.0.5 spec/looper_spec.rb
bigbench-0.0.4 spec/looper_spec.rb
bigbench-0.0.3 spec/looper_spec.rb
bigbench-0.0.2 spec/looper_spec.rb