Fastest way in ruby to gain all files in a directory?


I benchmarked:

Dir.entries() is faster than Dir[]

But is there another way to be even faster?

I need to be able to be as fast as possible to get
all entries in a directory.

Diving into C would also be fine (if this would
then work from within ruby though).

So far Dir.entries seems faster than Dir[] / Dir.glob

“ls” in bash is lightning fast. Is there any way to be
similarly fast in ruby?

Hi Robert,

You can do system calls in ruby.

ruby -e “exec(‘ls -al’)”