Sha256: dd01945ad6cdd936e343ae0100c73ba4fe47c78387ce5ed0f8b08c3dc19aa7eb
Contents?: true
Size: 1.34 KB
Versions: 8
Compression:
Stored size: 1.34 KB
Contents
$:.unshift("lib") require 'rod' module RodTest class Model < Rod::Model end %w{E D C B A}.each do |letter| klass = Class.new(Model) do 10.times do |i| field "a#{i}".to_sym, :ulong end end const_set("#{letter}Struct",klass) klass.send(:build_structure) end class EffectivenessTest MAGNITUDE = 100000 FILENAME = "tmp/eff2" def setup @structs = {} %w{A B C D E}.each do |letter| @structs[letter.to_sym] = [] (MAGNITUDE).times do |i| @structs[letter.to_sym][i] = RodTest.const_get("#{letter}Struct").new 10.times do |j| @structs[letter.to_sym][i].send("a#{j}=",j) end end end end def main start_t = Time.now.to_f Model.instance.create_database(FILENAME) %w{A B C D E}.each do |letter| (MAGNITUDE / 2).times {|i| @structs[letter.to_sym][i].store } end %w{A B C D E}.each do |letter| (MAGNITUDE / 2).times {|i| @structs[letter.to_sym][MAGNITUDE/2 + i].store } end end_t = Time.now.to_f puts "Storing the objects in the DB took #{end_t - start_t} seconds" start_t = Time.now.to_f Model.close_database end_t = Time.now.to_f puts "Closing the DB took #{end_t - start_t} seconds" end end end e = RodTest::EffectivenessTest.new e.setup e.main
Version data entries
8 entries across 8 versions & 1 rubygems