From: Michael Davis Date: 2001-02-16T04:07:19+09:00 Subject: [ruby-talk:10924] Mashal.dump 10000 records, Marshal.load only reads 9939 records I have provided a small ruby script to test Marshal dump and how efficient it is. It Marshal.dumps 10000 arrays and then Marhsal.loads them back in. The problem is that it only reads 9895 rows. Is this a bug? Can someone tell me where 105 of my rows went? Here is the output from this script (on linux Red Hat 6.2 box) running with Ruby 1.6.1: Time test (using Marshal dump on Array): It took 0.503368 seconds to insert 10000 rows - End of file reached It took 0.595172 seconds to count the rows (9895) Here is the output running with Ruby 1.6.2: Time test (using Marshal dump on Array): It took 0.471307 seconds to insert 10000 rows - End of file reached It took 0.589883 seconds to count the rows (9939) Here is the Ruby script: print "\nTime test (using Marshal dump on Array):\n" fp = File.new("Membership.dmp", "w+") t = Time.now rows = 0 1.upto(10000) do |i| data = [i, 'Davis', 'Michael', 0] Marshal.dump(data, fp) rows += 1 end print " It took #{Time.now - t} seconds to insert ", rows, " rows\n" t = Time.now count = 0 rows = 0 fp2 = File.new("Membership.dmp", "r+") begin 1.upto(10000) do |i| data = Marshal.load(fp2) count += 1 if (data[0] > 9000) rows += 1 end rescue # we want to trap all errors and report them without failing print " - ", $!, "\n" end print " It took #{Time.now - t} seconds to count the rows (#{rows})\n"