Parent

Class/Module Index [+]

Quicksearch

Object

Public Instance Methods

show_progress(s, total, current) click to toggle source
# File lib/deep_test/metrics/queue_lock_wait_time_measurement.rb, line 123
def show_progress(s, total, current)
  if (current % (total / 5)) == 0
    $stdout.print s
    $stdout.flush
  end
end
test_measurement(thread_count, action_count) click to toggle source
# File lib/deep_test/metrics/queue_lock_wait_time_measurement.rb, line 80
def test_measurement(thread_count, action_count)
  q = Queue.new
  q.extend DeepTest::Metrics::QueueLockWaitTimeMeasurement

  threads = []
  thread_count.times do
    threads << Thread.new do
      action_count.times do |i|
        show_progress ".", action_count, i
        q.push 1
      end
    end
  end

  thread_count.times do
    threads << Thread.new do
      action_count.times do |i|
        show_progress "-", action_count, i
        if rand(2) == 0
          begin
            q.pop(true)
          rescue ThreadError
          end
        else
          begin
            Timeout.timeout(0.01) do
              q.pop
            end
          rescue Timeout::Error
            break
          end
        end
      end
    end
  end

  threads.each {|t| t.join}

  puts
  puts "Push Time: #{q.total_push_time}"
  puts "Pop Time:  #{q.total_pop_time}"
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.