Project

General

Profile

Actions

Feature #3001

closed

Ruby stdlib: Benchmark::Tms #memberwise drops labels

Feature #3001: Ruby stdlib: Benchmark::Tms #memberwise drops labels

Added by DrErnie (Ernest Prabhakar) over 15 years ago. Updated over 9 years ago.

Status:
Feedback
Assignee:
-
Target version:
-
[ruby-core:28908]

Description

=begin
http://ruby-doc.org/stdlib/libdoc/benchmark/rdoc/classes/Benchmark/Tms.html#M000016-source

The implementation of Benchmark::Tms#memberwise only passes the computed time values when creating a new instance, e.g.:

     Benchmark::Tms.new(utime.__send__(op, x),
                        stime.__send__(op, x),
                        cutime.__send__(op, x),
                        cstime.__send__(op, x),
                        real.__send__(op, x)
                        )

It would seem consistent (and more informative) if it also passed in the current label (especially since there's no other way to set it):

     Benchmark::Tms.new(utime.__send__(op, x),
                        stime.__send__(op, x),
                        cutime.__send__(op, x),
                        cstime.__send__(op, x),
                        real.__send__(op, x),
                        label
                        )

Example:

t = Benchmark.measure("foo") { sleep 0.1 }
=> #<Benchmark::Tms:0x1011d03d8 @cstime=0.0, @total=0.0, @cutime=0.0, @label="foo", @stime=0.0, @real=0.100059986114502, @utime=0.0>
t2 = t / 2
=> #<Benchmark::Tms:0x1011be6d8 @cstime=0.0, @total=0.0, @cutime=0.0, @label=nil, @stime=0.0, @real=0.050029993057251, @utime=0.0>
=end

Updated by mame (Yusuke Endoh) over 15 years ago Actions #1

=begin
Hi,

It would seem consistent (and more informative) if it also passed in the current label (especially since there's no other way to set it):

It is confusing to preserve the entirely same label, I guess.

If you really need the feature, a "derived" mark would be better,
such as "foo (/ 2)"

Viewed in this light, this is a new feature rather than bug.
So I move this ticket into Feature tracker.

--
Yusuke Endoh
=end

Updated by mame (Yusuke Endoh) over 15 years ago Actions #2

  • Target version set to 2.0.0

=begin

=end

Updated by drbrain (Eric Hodel) over 14 years ago Actions #3 [ruby-core:38556]

  • Category set to lib

Updated by Eregon (Benoit Daloze) over 14 years ago Actions #4 [ruby-core:38562]

Hi,

It would seem consistent (and more informative) if it also passed in the current label (especially since there's no other way to set it):

What about (tms1 + tms2)'s label ? Should it be "#{tms1.label} #{op} #{tms2.label}" ?
It seems consistent for operations with both Tms and others ("foo / 2").

But I'm not sure how this would be useful, could you give me an example ?
Maybe the need is somewhere else.

Updated by nahi (Hiroshi Nakamura) over 13 years ago Actions #5 [ruby-core:43399]

  • Status changed from Open to Feedback

Updated by ko1 (Koichi Sasada) about 13 years ago Actions #6 [ruby-core:48338]

  • Target version changed from 2.0.0 to 2.6

I changed target to next minor because there is no discussion on it.
No feedback?

Updated by cjeon (CHEOLHO JEON) over 9 years ago Actions #7 [ruby-core:75703]

Ernest Prabhakar wrote:

=begin
http://ruby-doc.org/stdlib/libdoc/benchmark/rdoc/classes/Benchmark/Tms.html#M000016-source

The implementation of Benchmark::Tms#memberwise only passes the computed time values when creating a new instance, e.g.:

     Benchmark::Tms.new(utime.__send__(op, x),
                        stime.__send__(op, x),
                        cutime.__send__(op, x),
                        cstime.__send__(op, x),
                        real.__send__(op, x)
                        )

It would seem consistent (and more informative) if it also passed in the current label (especially since there's no other way to set it):

     Benchmark::Tms.new(utime.__send__(op, x),
                        stime.__send__(op, x),
                        cutime.__send__(op, x),
                        cstime.__send__(op, x),
                        real.__send__(op, x),
                        label
                        )

Example:

t = Benchmark.measure("foo") { sleep 0.1 }
=> #<Benchmark::Tms:0x1011d03d8 @cstime=0.0, @total=0.0, @cutime=0.0, @label="foo", @stime=0.0, @real=0.100059986114502, @utime=0.0>
t2 = t / 2
=> #<Benchmark::Tms:0x1011be6d8 @cstime=0.0, @total=0.0, @cutime=0.0, @label=nil, @stime=0.0, @real=0.050029993057251, @utime=0.0>
=end

any update on this? I think it should not drop labels...

Actions

Also available in: PDF Atom