[#64517] Fw: Re: Ruby and Rails to become Apache Incubator Project — Tetsuya Kitahata <[email protected]>

What do you think? >> Ruby developers

13 messages 2014/08/23

[#64615] [ruby-trunk - Feature #10181] [Open] New method File.openat() — oss-ruby-lang@...

Issue #10181 has been reported by Technorama Ltd..

10 messages 2014/08/28
[#64616] Re: [ruby-trunk - Feature #10181] [Open] New method File.openat() — Eric Wong <normalperson@...> 2014/08/28

I like this feature.

[#64671] Fwd: [ruby-changes:35240] normal:r47322 (trunk): symbol.c (rb_sym2id): do not return garbage object — SASADA Koichi <ko1@...>

Why this fix solve your problem?

9 messages 2014/08/30
[#64672] Re: Fwd: [ruby-changes:35240] normal:r47322 (trunk): symbol.c (rb_sym2id): do not return garbage object — SASADA Koichi <ko1@...> 2014/08/30

(2014/08/30 8:50), SASADA Koichi wrote:

[ruby-core:64523] [ruby-trunk - Feature #10165] Use Process.clock_gettime to speed up Benchmark.realtime.

From: normalperson@...
Date: 2014-08-24 02:19:54 UTC
List: ruby-core #64523
Issue #10165 has been updated by Eric Wong.


 Thanks Pete!  I committed your patch as r47260.
 I couldn't resist, so I also made r47622 to modify measure, too.
 (smaller improvement, 1.30s vs 1.44s on my VM)
 
 	require 'benchmark'
 	p(Benchmark.measure { 100000.times { Benchmark.measure {} } })

----------------------------------------
Feature #10165: Use Process.clock_gettime to speed up Benchmark.realtime.
https://bugs.ruby-lang.org/issues/10165#change-48461

* Author: Pete Higgins
* Status: Closed
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
----------------------------------------
This patch changes the Benchmark.realtime method to use the Process.clock_gettime internally when generating the time elapsed. Calling Process.clock_gettime is faster than the current way of creating Time objects.

I wrote a benchmark script (also attached) to demonstrate the difference:

```
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
```

When I run this on my local machine I see this output:

```
1000000 iterations.
Rehearsal ---------------------------------------
old   0.860000   0.000000   0.860000 (  0.863118)
new   0.360000   0.000000   0.360000 (  0.355242)
------------------------------ total: 1.220000sec

          user     system      total        real
old   0.870000   0.010000   0.880000 (  0.866577)
new   0.330000   0.000000   0.330000 (  0.328982)
```

I discussed this idea originally with Eric Hodel, but he has not reviewed this code.

---Files--------------------------------
benchmark_benchmark_realtime.rb (424 Bytes)
faster_benchmark_realtime.diff (909 Bytes)
faster_benchmark_realtime_2.diff (1.1 KB)


-- 
https://bugs.ruby-lang.org/

In This Thread

Prev Next