[#28561] Ruby::DL vs Ruby::FFI — Aston <blackapache512-ticket@...>

Ruby.DL and FFI libraries are great for programmers like me who are not internet programmers, but are more interested in scientific and number processing etc.

11 messages 2010/03/08

[#28686] trunk (26947) build fail with msys/mingw/vista — Jon <jon.forums@...>

I get the following build failure when msysgit's "c:\git\cmd" dir is on PATH.

8 messages 2010/03/16

[#28687] [Bug #2973] rb_bug - Segmentation fault - error.c:213 — rudolf gavlas <redmine@...>

Bug #2973: rb_bug - Segmentation fault - error.c:213

10 messages 2010/03/16

[#28735] [Bug #2982] Ruby tries to link with both openssl and readline — Lucas Nussbaum <redmine@...>

Bug #2982: Ruby tries to link with both openssl and readline

16 messages 2010/03/18

[#28736] [Bug #2983] Ruby (GPLv2 only) tries to link to with readline (now GPLv3) — Lucas Nussbaum <redmine@...>

Bug #2983: Ruby (GPLv2 only) tries to link to with readline (now GPLv3)

10 messages 2010/03/18

[#28907] [Bug #3000] Open SSL Segfaults — Christian Höltje <redmine@...>

Bug #3000: Open SSL Segfaults

19 messages 2010/03/23

[#28924] [Bug #3005] Ruby core dump - [BUG] rb_sys_fail() - errno == 0 — Sebastian YEPES <redmine@...>

Bug #3005: Ruby core dump - [BUG] rb_sys_fail() - errno == 0

10 messages 2010/03/24

[#28954] [Feature #3010] slow require gems in ruby 1.9.1 — Miao Jiang <redmine@...>

Feature #3010: slow require gems in ruby 1.9.1

15 messages 2010/03/24

[#29179] [Bug #3071] Convert rubygems and rdoc to use psych — Aaron Patterson <redmine@...>

Bug #3071: Convert rubygems and rdoc to use psych

10 messages 2010/03/31

[ruby-core:28766] [Feature #2065] An ancestors iterator

From: Simon Chiang <redmine@...>
Date: 2010-03-18 20:38:37 UTC
List: ruby-core #28766
Issue #2065 has been updated by Simon Chiang.

File cache_benchmark.rb added

Ok, I attached a benchmark that is designed to measure the time required for generating the ancestors array. It does so by comparing 'klass.ancestors.each' vs caching 'klass.ancestor' and iterating 'cache.each' (ie in the second case the ancestors array is only generated once).

Running the attached script I get results like the following:

  % ruby cache_benchmark.rb 
  Benchmark without cache
                            user     system      total        real
  A.value(:one)         0.300000   0.000000   0.300000 (  0.307086)
  B.value(:two)         0.310000   0.000000   0.310000 (  0.305512)
  C.value(:three)       0.310000   0.000000   0.310000 (  0.307264)
 
  Benchmark with cache
                          user     system      total        real
  A.value(:one)         0.240000   0.000000   0.240000 (  0.242152)
  B.value(:two)         0.240000   0.000000   0.240000 (  0.244592)
  C.value(:three)       0.250000   0.000000   0.250000 (  0.243842)
  Array.new             0.050000   0.000000   0.050000 (  0.058072)

This is for 100k iterations, so no it's not a bottleneck but likewise that's not why I make this request. I make the request because it would be significantly faster to not generate the ancestors array each time (~20% in this case, which illustrates what is probably the maximum increase for getting an each_ancestor iterator). Notice that the increase in performance corresponds neatly with the time it take to generate 100k arrays.

I imagine somewhere the in-memory ancestry is iterated to make the ancestors array, right? If so I think exposing that iterator would be helpful to DSLs that implement method-like inheritance.

Also I agree that adding each_* methods for every method that return an array would be ridiculous but I'm only asking for a specific one with a specific purpose ;) 

The module include method may work to the same end -- I need to explore further -- but I still make this request because it would be less technical to use an each_ancestor iterator, and ultimately less error-prone given all the things that ruby can do with including, extending, undefining and redefining constants. Thank you for the suggestion, and for looking at this.



----------------------------------------
http://redmine.ruby-lang.org/issues/show/2065

----------------------------------------
http://redmine.ruby-lang.org

In This Thread

Prev Next