Sha256: 1847d9a0861417facc99adb4d87e90e00f5d369e018354485ec8068cd6e54592
Contents?: true
Size: 1.35 KB
Versions: 2
Compression:
Stored size: 1.35 KB
Contents
# TestDiff module module TestDiff # estimates and prints how long it will take to empty a queue class TimingTracker def self.run(queue, &block) new(queue).run(&block) end include Logging def initialize(queue) @queue = queue @original_size = queue_size end def run @start_time = Time.now thread = start_timing_thread yield thread.kill end private def queue_size @queue.size end def seconds_elapsed (Time.now - @start_time).to_f end def start_timing_thread Thread.new do begin do_timing rescue => e log_error "----- Timing failed: #{e.message} -----" end end end def do_timing log_info "Timing #{@original_size} specs" sleep_time = 90.0 until queue_empty? last_current_size = queue_size sleep(sleep_time) current_size = queue_size current_completed = last_current_size - current_size if current_completed > 0 est_time_left = (sleep_time / current_completed.to_f) * current_size log_info "specs left #{current_size}, est time_left: #{est_time_left.to_i}" else log_info "specs left #{current_size}, est time_left: N/A" end end end def queue_empty? @queue.empty? end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
test_diff-0.6.0 | lib/test_diff/timing_tracker.rb |
test_diff-0.5.0 | lib/test_diff/timing_tracker.rb |