Sha256: 727e3f1c0dcc5a11ffafc32ef33d768102bc1ea991b080f4637e5eb4415b9837

Contents?: true

Size: 890 Bytes

Versions: 62

Compression:

Stored size: 890 Bytes

Contents

# encoding: UTF-8
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')

raise Mysql2::Mysql2Error.new("GC allocation benchmarks only supported on Ruby 1.9!") unless RUBY_VERSION =~ /1\.9/

require 'rubygems'
require 'benchmark'
require 'active_record'

ActiveRecord::Base.default_timezone = :local
ActiveRecord::Base.time_zone_aware_attributes = true

class Mysql2Model < ActiveRecord::Base
  set_table_name :mysql2_test
end

def bench_allocations(feature, iterations = 10, &blk)
  puts "GC overhead for #{feature}"
  Mysql2Model.establish_connection(:adapter => 'mysql2', :database => 'test')
  GC::Profiler.clear
  GC::Profiler.enable
  iterations.times{ blk.call }
  GC::Profiler.report(STDOUT)
  GC::Profiler.disable
end

bench_allocations('coercion') do
  Mysql2Model.all(:limit => 1000).each{ |r|
    r.attributes.keys.each{ |k|
      r.send(k.to_sym)
    }
  }
end

Version data entries

62 entries across 62 versions & 7 rubygems

Version Path
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/mysql2-0.3.11/benchmark/allocations.rb
mysql2-0.2.19b4 benchmark/allocations.rb
mysql2-0.3.12b4 benchmark/allocations.rb
mysql2-0.2.19b3 benchmark/allocations.rb
mysql2-0.3.12b3 benchmark/allocations.rb
mysql2-0.3.12b2 benchmark/allocations.rb
mysql2-0.2.19b2 benchmark/allocations.rb
mysql2-0.3.12b1 benchmark/allocations.rb
mysql2-0.2.19b1 benchmark/allocations.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/mysql2-0.3.11/benchmark/allocations.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/mysql2-0.3.11/benchmark/allocations.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/mysql2-0.3.11/benchmark/allocations.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/mysql2-0.3.11/benchmark/allocations.rb
sunrise-cms-0.3.0.rc vendor/bundle/ruby/1.9.1/gems/mysql2-0.3.11/benchmark/allocations.rb
mysql2-sp-0.3.10 benchmark/allocations.rb
solaris-mysql2-0.3.11 benchmark/allocations.rb
mysql2-0.3.11-x86-mswin32-60 benchmark/allocations.rb
mysql2-0.3.11-x86-mingw32 benchmark/allocations.rb
mysql2-0.3.11 benchmark/allocations.rb
mysql2-0.2.18-x86-mswin32-60 benchmark/allocations.rb