Class: Tribe::Benchmark::Throughput::MyData

Inherits:
Object
  • Object
show all
Defined in:
lib/tribe/benchmark/throughput.rb

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ MyData

Returns a new instance of MyData.



35
36
37
38
39
# File 'lib/tribe/benchmark/throughput.rb', line 35

def initialize(name)
  @name = name
  @counter = 0
  @start_time = Time.now
end

Instance Method Details

#incrementObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/tribe/benchmark/throughput.rb', line 41

def increment
  @counter += 1

  if @counter >= MAX_INCR
    $lock.synchronize do
      $finished += 1

      if $finished == COUNTERS
        puts "\nFinished! Rate=#{(COUNTERS * MAX_INCR).to_f / (Time.now.utc - $start_time).to_f } msgs/sec\n"
      end
    end

    return false
  end

  return true
end