From: "ara.t.howard" Date: 2007-10-08T23:27:46+09:00 Subject: Re: [ANN] Find On Oct 7, 2007, at 6:41 AM, Bertram Scharpf wrote: > Hi, > > the Ruby built-in Find module lacks a lot of features the > GNU find tools has. I wrote a new one (~170 lines). > > > > Maybe somebody likes it. > this is one of the very smallest directories i am working with: [cfadmin@yacht cfadmin]$ find /mnt/yacht0/data/night_files/|wc -l 69287 [cfadmin@yacht cfadmin]$ ruby a.rb user system total real bertram.scharpf.find 2.140000 1.230000 3.370000 ( 7.602333) alib.util.find 1.360000 0.440000 1.800000 ( 1.812519) [cfadmin@yacht cfadmin]$ cat a.rb require 'benchmark' require 'alib' require 'bertram.scharpf.find.rb' top = '/mnt/yacht0/data/night_files/' Benchmark.bm do |b| b.report('bertram.scharpf.find'){ Find.open(top){|x|} } b.report('alib.util.find'){ alib.util.find(top){|x|} } end also there is alib.util.find2 which yields the stat together with the path, preventing and extra stat on the pathname. in practice doing something like def method_missing m, *a, &b stat.send m, *a, &b end means you have to use a ton of code since it's possible that f.size ### no error f.mtime ### ENOENT btw mine http://codeforpeople.com/lib/ruby/alib/alib-0.5.0/lib/alib-0.5.0/ find2.rb isn't a spectacular implementation, it is based on Motoyuki Kasahara's 2001 lib, which used to be on the raa, called find2 - but it's reasonably fast, does depth and breath, caches stats, and handles files evaporation from the filesystem or not being accessible due to permissions errors. i think all these libraries prove that a new find mechanism needs to be incorporated into the stdlib! we should take the best features from all the various libs and propose a new library that is backward compatible with the built-in find. kind regards. a @ http://codeforpeople.com/ -- it is not enough to be compassionate. you must act. h.h. the 14th dalai lama