Benchmark question

(J-Van) #1

irb(main):015:0> Benchmark.measure { 1000000.times { |i| i + 1 } }
=>
#<Benchmark::Tms:0x400fa914 @cutime=0.0, @label="", @stime=0.0,
@real=0.514808893203735, @utime=4.95, @cstime=0.0, @total=4.95>

Why is user time bigger than real time? I'm confused by the
relationship between these numbers.

(Mohit Muthanna) #2

What version of Ruby are you on?

Here's what I see:

mohit@reddwarf log $ irb
irb(main):001:0> require 'benchmark'
=> true
irb(main):002:0> Benchmark.measure{ 1000000.times{ |i| i + 1 } }
=> #<Benchmark::Tms:0xb7d57984 @cutime=0.0, @label="", @stime=0.0,
@real=0.589663028717041, @utime=0.59, @cstime=0.0, @total=0.59>
irb(main):004:0> quit
mohit@reddwarf log $ ruby -v
ruby 1.8.2 (2004-12-25) [i686-linux]
mohit@reddwarf log $

Real time on my results are also lower than user time. But this may be
a floating-point precision thing.

I think your version of Benchmark is expressing "real time" in
seconds, and the others in centi-seconds.

Mohit.

> irb(main):015:0> Benchmark.measure { 1000000.times { |i| i + 1 } }
> =>
> #<Benchmark::Tms:0x400fa914 @cutime=0.0, @label="", @stime=0.0,
> @real=0.514808893203735, @utime=4.95, @cstime=0.0, @total=4.95>
>
> Why is user time bigger than real time? I'm confused by the
> relationship between these numbers.
>
>

--
Mohit Muthanna [mohit (at) muthanna (uhuh) com]
"There are 10 types of people. Those who understand binary, and those
who don't."

···

On 8/26/05, Joe Van Dyk <joevandyk@gmail.com> wrote:

--
Mohit Muthanna [mohit (at) muthanna (uhuh) com]
"There are 10 types of people. Those who understand binary, and those
who don't."

(J-Van) #3

ruby 1.8.2, compiled on Redhat 9.

···

On 8/27/05, Mohit Muthanna <mohit.muthanna@gmail.com> wrote:

> What version of Ruby are you on?
>
> Here's what I see:
>
> mohit@reddwarf log $ irb
> irb(main):001:0> require 'benchmark'
> => true
> irb(main):002:0> Benchmark.measure{ 1000000.times{ |i| i + 1 } }
> => #<Benchmark::Tms:0xb7d57984 @cutime=0.0, @label="", @stime=0.0,
> @real=0.589663028717041, @utime=0.59, @cstime=0.0, @total=0.59>
> irb(main):004:0> quit
> mohit@reddwarf log $ ruby -v
> ruby 1.8.2 (2004-12-25) [i686-linux]
> mohit@reddwarf log $
>
> Real time on my results are also lower than user time. But this may be
> a floating-point precision thing.
>
> I think your version of Benchmark is expressing "real time" in
> seconds, and the others in centi-seconds.
>
> Mohit.
>
> On 8/26/05, Joe Van Dyk <joevandyk@gmail.com> wrote:
> > irb(main):015:0> Benchmark.measure { 1000000.times { |i| i + 1 } }
> > =>
> > #<Benchmark::Tms:0x400fa914 @cutime=0.0, @label="", @stime=0.0,
> > @real=0.514808893203735, @utime=4.95, @cstime=0.0, @total=4.95>
> >
> > Why is user time bigger than real time? I'm confused by the
> > relationship between these numbers.
> >
> >
>
>
> --
> Mohit Muthanna [mohit (at) muthanna (uhuh) com]
> "There are 10 types of people. Those who understand binary, and those
> who don't."
>

--
Mohit Muthanna [mohit (at) muthanna (uhuh) com]
"There are 10 types of people. Those who understand binary, and those
who don't."