Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/benchmark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ def add!(&blk)
@cutime = cutime + t.cutime
@cstime = cstime + t.cstime
@real = real + t.real
@total = total + t.total
self
end

Expand Down
9 changes: 9 additions & 0 deletions test/benchmark/test_benchmark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,15 @@ def test_bugs_ruby_dev_40906_can_add_in_place_the_time_of_execution_of_the_block
assert_not_equal(0, t.real)
end

# TODO: Consider combining with the above test
def test_add_in_place
t = Benchmark::Tms.new
assert_equal(0, t.total)

t.add! { 1000.times do ; '1'; end }
assert_not_equal(0, t.total)
end

def test_realtime_output
sleeptime = 1.0
realtime = Benchmark.realtime { sleep sleeptime }
Expand Down