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

Hi,

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’)”

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs