Project

General

Profile

Actions

Bug #4940

closed

Fixes for the benchmark library

Added by Eregon (Benoit Daloze) almost 13 years ago. Updated over 12 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 1.9.3dev (2011-06-27 trunk 32247) [x86_64-darwin10.7.0]
Backport:
[ruby-core:37593]

Description

Hello,

Seeing the 1.9.3 release coming, I thought it was a good time to introduce some small fixes for the benchmark library.

You can see the commits on my benchmark branch, after the Merge commit: https://github.com/eregon/ruby/compare/trunk...benchmark

The changes are:
lib/benchmark (Benchmark#bmbm): bmbm should be consistent with bm for the return value
lib/benchmark (Benchmark#bmbm): remove useless explicit call, #format is an alias of #to_s
test/benchmark: add a test for format of long time

test/benchmark: remove preemptive test instead of skipping
I removed the preemptive test I wrote for Feature #4197.
I'll add it back when the implementation will be able to satisfy it.

lib/benchmark: fix label width: always add 1 to ensure there is a space delimiter even with times over 100s
When I asked for Feature #4197, I wanted to make delimiting spaces consistent for #bm and #bmbm.
I thought #bmbm was adding an extra space, compared to #bm, and so I removed that space.
But with times over 100s, the output contains no space between the label and the first time (user).
Now both ensure there is always a space, even if that means 3 spaces with times under 10s (because it is formatted as %10.6f)

test/benchmark: let labels be a constant
lib/benchmark (Benchmark#realtime): avoid creating an unused Proc
lib/benchmark (Benchmark#benchmark): use ensure clause to restore STDOUT.sync, as in #bmbm

Please let me know what I can do to help committing these changes.
I am assigning to Yui since he took care of the previous issue, feel free to change.

Thank you, and may 1.9.3 be a great release !

Actions #1

Updated by naruse (Yui NARUSE) over 12 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r32269.
Benoit, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • lib/benchmark.rb: merge eregon/benchmark.
    https://github.com/eregon/ruby/tree/benchmark
    patched by Benoit Daloze. [ruby-core:37593] [Bug #4940]

  • lib/benchmark (Benchmark#bmbm): bmbm should be consistent with bm
    for the return value.

  • test/benchmark: remove preemptive test instead of skipping
    I removed the preemptive test I wrote for Feature #4197.
    I'll add it back when the implementation will be able to satisfy it.

  • lib/benchmark (Benchmark#bmbm): remove useless explicit call,
    #format is an alias of #to_s test/benchmark: add a test for
    format of long time.

  • lib/benchmark: fix label width: always add 1 to ensure there is a
    space delimiter even with times over 100s
    When I asked for Feature #4197, I wanted to make delimiting spaces
    consistent for #bm and #bmbm.
    But with times over 100s, the output contains no space between the
    label and the first time (user).
    Now both ensure there is always a space, even if that means 3 spaces
    with times under 10s (because it is formatted as %10.6f)

  • test/benchmark: let labels be a constant
    lib/benchmark (Benchmark#realtime): avoid creating an unused Proc
    lib/benchmark (Benchmark#benchmark): use ensure clause to restore
    STDOUT.sync, as in #bmbm

Actions

Also available in: Atom PDF

Like0
Like0