How to understand the Benchmark result

D

Deepak Gole

[Note: parts of this message were removed to make it a legal post.]

Hi

I had ran 2 methods against Benchmark and got following output. But didn't
understand which method is faster and what is "elapsed real time".

*1st Method benchmark result
*user CPU time system CPU time
0.235000 0.015000 0.250000 ( 6.797000)


*2nd Method benchmark result
*user CPU time system CPU time
18.906000 0.250000 19.156000 ( 19.250000)*
*
 
S

Sandor Szücs

I had ran 2 methods against Benchmark and got following output. But =20=
didn't
understand which method is faster and what is "elapsed real time".

*1st Method benchmark result
*user CPU time system CPU time
0.235000 0.015000 0.250000 ( 6.797000)


*2nd Method benchmark result
*user CPU time system CPU time
18.906000 0.250000 19.156000 ( 19.250000)*
*


The first method is faster because it didn't consume as much CPU time
as the second.
IIRC the different times mean the following:
The first method took 0.235 seconds of user land CPU time (x86 speak: =20=

Ring3)
The second method took 0.015 seconds of kernel land CPU time (x86 =20
speak: Ring0)
The third time is the total time which is user land + kernel land CPU =20=

time
The fourth time is the time which was really taken.

Maybe an interesting example to understand the difference between =20
total and real
is:

# Runs a benchmark with blocking I/O and wait some time, before =20
writing some data
# through the pipe.
irb(main):020:0> Benchmark.bm do |x|
irb(main):021:1* x.report { File.open("/tmp/myfifo", 'r') {|f| =20
f.read(4)}}
irb(main):022:1> end
user system total real
0.000000 0.000000 0.000000 ( 6.760203)
=3D> true
$ echo bla > /tmp/myfifo # at another shell


# Write some data through the pipe and then run a benchmark with =20
blocking I/O.
$ echo bla > /tmp/myfifo
irb(main):023:0> Benchmark.bm do |x|
irb(main):024:1* x.report { File.open("/tmp/myfifo", 'r') {|f| =20
f.read(4)}}
irb(main):026:1* end
user system total real
0.000000 0.000000 0.000000 ( 0.000236)


hth. regards, Sandor Sz=FCcs
--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top