Feature #3001

Ruby stdlib: Benchmark::Tms #memberwise drops labels

Added by Ernest Prabhakar about 4 years ago. Updated over 1 year ago.

[ruby-core:28908]
Status:Feedback
Priority:Low
Assignee:-
Category:lib
Target version:next minor

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 }
=> #
t2 = t / 2
=> #
=end

History

#1 Updated by Yusuke Endoh about 4 years ago

=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 mame@tsg.ne.jp
=end

#2 Updated by Yusuke Endoh about 4 years ago

  • Target version set to 2.0.0

=begin

=end

#3 Updated by Eric Hodel over 2 years ago

  • Category set to lib

#4 Updated by Benoit Daloze over 2 years ago

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.

#5 Updated by Hiroshi Nakamura about 2 years ago

  • Status changed from Open to Feedback

#6 Updated by Koichi Sasada over 1 year ago

  • Target version changed from 2.0.0 to next minor

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

Also available in: Atom PDF