From: Markus Arike Date: 2008-03-04T13:21:22+09:00 Subject: Re: Better performance than native unix commands? Ma Sa wrote: > I have an issue with nfs and listing a large amount of files that I am > wondering if I can solve with ruby. I know that ruby has better > performance in some instances than a bash shell script so I am wondering > if anyone has experience or some examples of how this might work... > > I have a directory with a large amount of files that is mounted over > nfs. The network is gigabit and so are the nic's. The servers are very > high end so the hardware / network performance is not the bottleneck. > However, sometimes it can take a very long time to list out the files > contained within a directory. > > I will do an ls and it might take 5 minutes to retrieve a response. > > Would this be faster if I were to do the same ls function using the ruby > api? The only way to know for sure would be make some simple tests. I just ran these using the Dir class: Macintosh:~ marike$ time ruby -e 'd = Dir.new("."); d.each {|x| puts x}' | wc 162 166 1761 real 0m0.027s user 0m0.019s sys 0m0.010s Macintosh:~ marike$ time ls -A | wc 160 164 1756 real 0m0.008s user 0m0.005s sys 0m0.006s ls does appear to be faster, but I'm sure others on this list know a better Ruby way than that iterating over a Dir object. Markus -- Posted via http://www.ruby-forum.com/.