I get these results consistently where curb’s user, system and total
times are dramatically lower than Net::HTTP’s. However, Net:HTTP is
reported to run faster by the real column. Shouldn’t the reported real
time be consistent with the other columns?
I’m running this benchmark on a 2.4Ghz Core 2 Duo with 2GB RAM MacBook
Pro, if that helps.
time be consistent with the other columns?
No. “real” measures the time that is passed from start to finish.
Pseudocode
real_start = Time.now
yield # run test
real_end = Time.now
real_start.to_f - real_end.to_f
If the Kernel of your OS schedules another processes for, say 20
seconds,
then the difference between total and real is >= 20 seconds.
I think the time called “real” should not be trusted in an evaluation.
times are dramatically lower than Net::HTTP’s. However, Net:HTTP is
If the Kernel of your OS schedules another processes for, say 20 seconds,
then the difference between total and real is >= 20 seconds.
I think the time called “real” should not be trusted in an evaluation.
Not so fast. If another process has been running that may well be a
process spawned by our process.
13:19:09 Temp$ ruby19 bb.rb
user system total real
other process 0.000000 0.000000 0.139000 ( 10.375000)
in process 4.594000 0.000000 4.594000 ( 4.765000)
13:19:30 Temp$ cat bb.rb
require ‘benchmark’
Benchmark.bm 20 do |b|
b.report ‘other process’ do
system *%w{sleep 10}
end
b.report ‘in process’ do
10_000_000.times {|i| i + 1}
end
end
13:19:35 Temp$
I’d check the curl lib - I would assume that it uses the command line
utility of the same name - which then is another process.
If the Kernel of your OS schedules another processes for, say 20
seconds,
then the difference between total and real is >= 20 seconds.
I think the time called “real” should not be trusted in an
evaluation.
Not so fast. If another process has been running that may well be a
process spawned by our process.
Full ack that’s right, if a process forks, like system() do you can
measure
that one too.
Benchmark.bm(20) do |b|
b.report ‘fork’ do
pid = Process.fork { sleep 3 }
Process.waitpid pid
end
end
user system total real
fork 0.000000 0.010000 0.020000 ( 3.008273)
regards, Sandor
Szücs
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.