From: Bill Kelly Date: 2003-12-11T11:02:19+09:00 Subject: Re: [Q] Fast loading of BIG data structures Hi, From: "Steven Lumos" [...] > My question is: Is there an even faster way to load a big structure > than this? > > My first thought was to use Marshal, but I was surprised to find that > Marshal.load takes about twice as long as require: > > $ ruby -v > ruby 1.8.0 (2003-08-04) [sparc-solaris2.8] > $ time ruby -e "require 'network'" > real 0m3.431s > user 0m3.080s > sys 0m0.200s > $ time ruby -e "File.open('network.dump') {|f| Marshal.load(f)}" > real 0m7.321s > user 0m6.880s > sys 0m0.170s On the off-chance it's something about the way Marshal is doing file IO (I've had it be slow under Windows), you might try for comparison: bin = File.open('network.dump', "rb") {|f| f.sysread(f.stat.size) } dat = Marshal.load(bin) ...just in case it might be faster... (On Windows, with Ruby 1.6.8, this made a considerable difference...) HTH, Bill