Sha256: f0422deabf76e0330e7dd96adbca45873ab9a726099656cc11eb23010517bbc3
Contents?: true
Size: 1.2 KB
Versions: 1
Compression:
Stored size: 1.2 KB
Contents
# * George Moschovitis <gm@navel.gr> # (c) 2004-2005 Navel, all rights reserved. # $Id: bench.rb 255 2005-02-10 12:45:32Z gmosx $ $:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib') require 'og' GC.disable config = { :adapter => 'sqlite', :database => 'test', :connection_count => 5 } class Article prop_accessor :title, String prop_accessor :body, String prop_accessor :hits, Fixnum prop_accessor :rate, Fixnum def initialize(title = nil, body = nil) @title = title @body = body @hits = rand(5) @rate = rand(100) end end Og::Database.drop_db!(config) db = Og::Database.new(config) # Benchmark the insert speed. Useful for finding # the improvement when using prepared statements. articles = [] 500.times do |i| articles << Article.new("Title#{i}", "Body#{i}") end sum = 0 min = 999999 max = -min 10.times do |i| db.exec "DELETE FROM #{Article::DBTABLE}" for article in articles article.oid = nil end Article.create("Dummy", "Dummy") t1 = Time.now articles.each do |a| a.save! end t2 = Time.now d = t2 - t1 sum += d min = d if d < min max = d if d > max puts "Insert test #{i}: #{d} seconds" end puts "Min: #{min}" puts "Max: #{max}" puts "Average: #{sum/10}"
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nitro-0.10.0 | benchmark/og/bench.rb |