Sha256: aa4772167f933c18b709943c668bef4111c3734be8616daad8d5e66b01beaa90

Contents?: true

Size: 800 Bytes

Versions: 1

Compression:

Stored size: 800 Bytes

Contents

require File.expand_path("../bm_helper", __FILE__)
require "throttler"

include Throttler

print "Enter batch size: "
batch_size = STDIN.gets.to_i
printed_at = Time.now
timestamps = []
found = 0

client = Barnie.new('Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-HK) AppleWebKit/533.18.1 (KHTML, like Gecko) Version/5.0.2 Safari/533.18.5')

isbns_fixture.each_slice(batch_size) do |isbns|
  client.isbns = isbns
  throttle("bm") { found += client.books.size }
  timestamps << Time.now

  if Time.now - printed_at > 5.0
    puts Time.now.strftime("%H:%M:%S").center(38, '-')
    printed_at = Time.now
    average = (timestamps.
      select { |ts| printed_at - ts < 60.0 }.size / 60.0).
      round(3)
    puts [timestamps.size, average, found].
      map { |w| w.to_s.center(8) }.join(' | ')
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
barnie-0.1.3 benchmarks/stress_test.rb