Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add benchmarks for storage engines
- Loading branch information
1 parent
fb4025e
commit 9c3d7e8
Showing
2 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
-- create_table(:innodb, {:force=>true, :options=>"ENGINE=InnoDB"}) | ||
-> 0.0237s | ||
-- create_table(:myisam, {:force=>true, :options=>"ENGINE=MyISAM"}) | ||
-> 0.0030s | ||
-- create_table(:archive, {:force=>true, :options=>"ENGINE=Archive"}) | ||
-> 0.0029s | ||
user system total real | ||
inserts with innodb storage engine 9.240000 0.870000 10.110000 ( 18.102314) | ||
inserts with myisam storage engine 5.890000 0.490000 6.380000 ( 8.401665) | ||
inserts with archive storage engine 5.900000 0.480000 6.380000 ( 8.426003) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
require "rubygems" | ||
require "benchmark" | ||
require "active_support" | ||
require "active_record" | ||
|
||
TIMES = 10_000 | ||
|
||
ActiveRecord::Base.establish_connection({ | ||
:adapter => 'mysql', | ||
:database => 'query_analyzer_test', | ||
:user => "root", | ||
:password => "" | ||
}) | ||
|
||
ActiveRecord::Schema.define do | ||
|
||
create_table :innodb, :force => true, :options => 'ENGINE=InnoDB' do |t| | ||
t.string :foo | ||
end | ||
|
||
create_table :myisam, :force => true, :options => 'ENGINE=MyISAM' do |t| | ||
t.string :foo | ||
end | ||
|
||
create_table :archive, :force => true, :options => 'ENGINE=Archive' do |t| | ||
t.string :foo | ||
end | ||
|
||
end | ||
|
||
class InnoDB < ActiveRecord::Base | ||
set_table_name :innodb | ||
end | ||
|
||
class MyISAM < ActiveRecord::Base | ||
set_table_name :myisam | ||
end | ||
|
||
class Archive < ActiveRecord::Base | ||
set_table_name :archive | ||
end | ||
|
||
class String | ||
def self.random(length=10) | ||
chars = ("a".."z").to_a | ||
string = "" | ||
1.upto(length) { |i| string << chars[rand(chars.size-1)]} | ||
return string | ||
end | ||
end | ||
|
||
Benchmark.bm do |b| | ||
b.report "inserts with innodb storage engine" do | ||
TIMES.times { InnoDB.create!(:foo => String.random) } | ||
end | ||
|
||
b.report "inserts with myisam storage engine" do | ||
TIMES.times { MyISAM.create!(:foo => String.random) } | ||
end | ||
|
||
b.report "inserts with archive storage engine" do | ||
TIMES.times { Archive.create!(:foo => String.random) } | ||
end | ||
end |