process.c: Use getrusage(2) in Process.times
if getrusage(2) is available, to improve precision of Process.times and its user like lib/benchmark.rb.
On macOS, since getrusage(2) has better precision than times(3), they are much improved like:
Process.times => #
puts Benchmark.measure { "a" * 1_000_000_000 } 0.340000 0.310000 0.650000 ( 0.674025)
puts Benchmark.measure { "a" * 1_000_000_000 } 0.343223 0.310037 0.653260 ( 0.674025)
On Linux, since struct rusage from getrusage(2) is used instead of struct tms from times(2), they are slightly improved like:
puts Benchmark.measure { "a" * 1_000_000_000 } 0.120000 0.040000 0.170000 ( 0.171621)
puts Benchmark.measure { "a" * 1_000_000_000 } 0.124000 0.048000 0.172000 ( 0.171621)
[ruby-dev:49471] [Feature #11952]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58935 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
process.c: Use getrusage(2) in Process.times
if getrusage(2) is available, to improve precision of Process.times and
its user like lib/benchmark.rb.
On macOS, since getrusage(2) has better precision than times(3),
they are much improved like:
Process.times
=> #
puts Benchmark.measure { "a" * 1_000_000_000 }
0.340000 0.310000 0.650000 ( 0.674025)
Process.times
=> #
puts Benchmark.measure { "a" * 1_000_000_000 }
0.343223 0.310037 0.653260 ( 0.674025)
On Linux, since struct rusage from getrusage(2) is used instead of struct tms
from times(2), they are slightly improved like:
Process.times
=> #
puts Benchmark.measure { "a" * 1_000_000_000 }
0.120000 0.040000 0.170000 ( 0.171621)
Process.times
=> #
puts Benchmark.measure { "a" * 1_000_000_000 }
0.124000 0.048000 0.172000 ( 0.171621)
[ruby-dev:49471] [Feature #11952]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58935 b2dd03c8-39d4-4d8f-98ff-823fe69b080e