Benchmark for select VS rb_thread_select

This commit is contained in:
Lourens Naudé 2010-08-08 23:49:44 +01:00 committed by Brian Lopez
parent 2609783aeb
commit 10ee025647
2 changed files with 22 additions and 2 deletions

View File

@ -48,6 +48,6 @@ namespace :bench do
define_bench_task :query_without_mysql_casting
define_bench_task :sequel
define_bench_task :allocations
end
# Load custom tasks
define_bench_task :thread_alone
end# Load custom tasks
Dir['tasks/*.rake'].sort.each { |f| load f }

20
benchmark/thread_alone.rb Normal file
View File

@ -0,0 +1,20 @@
# encoding: UTF-8
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
require 'rubygems'
require 'benchmark'
require 'mysql2'
iterations = 1000
client = Mysql2::Client.new(:host => "localhost", :username => "root", :database => "test")
query = lambda{ iterations.times{ client.query("SELECT mysql2_test.* FROM mysql2_test") } }
Benchmark.bmbm do |x|
x.report('select') do
query.call
end
x.report('rb_thread_select') do
thread = Thread.new{ sleep(10) }
query.call
thread.kill
end
end