Sha256: 47013e982e691f1157a06f60e975ea9a53cc462bfbf510b2907b0945ee41a62d

Contents?: true

Size: 1.54 KB

Versions: 21

Compression:

Stored size: 1.54 KB

Contents

require File.dirname(__FILE__) + '/base'
require 'taps/utils'

describe Taps::Chunksize do
  it "scales chunksize down slowly when the time delta of the block is just over a second" do
    Time.stubs(:now).returns(10.0).returns(11.5)
    Taps::Utils.calculate_chunksize(1000) { |c| }.should == 900
  end

  it "scales chunksize down fast when the time delta of the block is over 3 seconds" do
    Time.stubs(:now).returns(10.0).returns(15.0)
    Taps::Utils.calculate_chunksize(3000) { |c| }.should == 1000
  end

  it "scales up chunksize fast when the time delta of the block is under 0.8 seconds" do
    Time.stubs(:now).returns(10.0).returns(10.7)
    Taps::Utils.calculate_chunksize(1000) { |c| }.should == 2000
  end

  it "scales up chunksize slow when the time delta of the block is between 0.8 and 1.1 seconds" do
    Time.stubs(:now).returns(10.0).returns(10.8)
    Taps::Utils.calculate_chunksize(1000) { |c| }.should == 1100

    Time.stubs(:now).returns(10.0).returns(11.1)
    Taps::Utils.calculate_chunksize(1000) { |c| }.should == 1100
  end

  it "will reset the chunksize to a small value if we got a broken pipe exception" do
    Taps::Utils.calculate_chunksize(1000) do |c|
      raise Errno::EPIPE if c.chunksize == 1000
      c.chunksize.should == 10
    end.should == 10
  end

  it "will reset the chunksize to a small value if we got a broken pipe exception a second time" do
    Taps::Utils.calculate_chunksize(1000) do |c|
      raise Errno::EPIPE if c.chunksize == 1000 || c.chunksize == 10
      c.chunksize.should == 1
    end.should == 1
  end
end

Version data entries

21 entries across 21 versions & 5 rubygems

Version Path
taps2-0.5.5 spec/chunksize_spec.rb
taps2-0.5.4 spec/chunksize_spec.rb
taps2-0.5.3 spec/chunksize_spec.rb
taps2-0.5.2 spec/chunksize_spec.rb
taps2-0.5.1 spec/chunksize_spec.rb
tinroof-taps-0.3.24 spec/chunksize_spec.rb
tapsicle-0.4.1 spec/chunksize_spec.rb
taps-taps-0.3.24 spec/chunksize_spec.rb
taps-0.3.24 spec/chunksize_spec.rb
taps-0.3.23 spec/chunksize_spec.rb
taps-0.3.23.pre1 spec/chunksize_spec.rb
taps-0.3.22.pre2 spec/chunksize_spec.rb
taps-0.3.22.pre1 spec/chunksize_spec.rb
taps-0.3.21 spec/chunksize_spec.rb
taps-0.3.20 spec/chunksize_spec.rb
taps-0.3.20.pre2 spec/chunksize_spec.rb
taps-0.3.20.pre1 spec/chunksize_spec.rb
taps-0.3.19 spec/chunksize_spec.rb
taps-0.3.19.pre1 spec/chunksize_spec.rb
taps-0.3.18 spec/chunksize_spec.rb