⚲
Project
General
Profile
Sign in
Register
Home
Projects
Help
Search
:
Ruby master
All Projects
Ruby
»
Ruby master
Overview
Activity
Roadmap
Issues
Repository
Like
Download (424 Bytes)
Feature #10165
» benchmark_benchmark_realtime.rb
phiggins (Pete Higgins)
, 08/23/2014 08:58 PM
require
'benchmark'
def
old_benchmark
r0
=
Time
.
now
yield
Time
.
now
-
r0
end
def
new_benchmark
r0
=
Process
.
clock_gettime
(
Process
::
CLOCK_MONOTONIC
)
yield
Process
.
clock_gettime
(
Process
::
CLOCK_MONOTONIC
)
-
r0
end
n
=
(
ARGV
.
first
||
1_000_000
).
to_i
puts
"
#{
n
}
iterations."
Benchmark
.
bmbm
do
|
b
|
b
.
report
(
"old"
)
{
n
.
times
{
old_benchmark
{
nil
}
}
}
b
.
report
(
"new"
)
{
n
.
times
{
new_benchmark
{
nil
}
}
}
end
« Previous
1
2
3
Next »
(1-1/3)
Loading...