From 1d3c2819040864296d96de50f625496377b6ec57 Mon Sep 17 00:00:00 2001 From: Brian Lopez Date: Thu, 15 Apr 2010 13:00:39 -0700 Subject: [PATCH] add AR benchmark - mysql2 looks to be about 19% faster so far --- benchmark/active_record.rb | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 benchmark/active_record.rb diff --git a/benchmark/active_record.rb b/benchmark/active_record.rb new file mode 100644 index 0000000..0b32e18 --- /dev/null +++ b/benchmark/active_record.rb @@ -0,0 +1,39 @@ +# encoding: UTF-8 +$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib') + +require 'rubygems' +require 'benchmark' +require 'active_record' +require 'ruby-debug' + +number_of = 1 +mysql2_opts = { + :adapter => 'mysql2', + :database => 'test' +} +mysql_opts = { + :adapter => 'mysql', + :database => 'test' +} + +class TestModel < ActiveRecord::Base + set_table_name :mysql2_test +end + +Benchmark.bmbm do |x| + x.report do + TestModel.establish_connection(mysql2_opts) + puts "Mysql2" + number_of.times do + TestModel.all(:limit => 1000) + end + end + + x.report do + TestModel.establish_connection(mysql_opts) + puts "Mysql" + number_of.times do + TestModel.all(:limit => 1000) + end + end +end \ No newline at end of file