require 'rubygems' require 'active_record' $c = { :adapter => 'postgresql', :database => 'reality_development', :username => 'postgres', :password => '240374' } ActiveRecord::Base.establish_connection($c) require 'benchmark' class State < ActiveRecord::Base end def t1 State.find(:all).each {|s| s[:node_id]} end def t2 State.find(:all).each {|s| s.inspect} end #100.times {State.create :node_id => rand(1000), :quality => rand(6), :stamp => Time.now - rand(1000), # :value => rand(1000)} puts State.count n = 100 Benchmark.bm do |x| x.report {n.times {t1}} x.report {n.times {t2}} end