Benchmark for select VS rb_thread_select
This commit is contained in:
parent
2609783aeb
commit
10ee025647
4
Rakefile
4
Rakefile
@ -48,6 +48,6 @@ namespace :bench do
|
|||||||
define_bench_task :query_without_mysql_casting
|
define_bench_task :query_without_mysql_casting
|
||||||
define_bench_task :sequel
|
define_bench_task :sequel
|
||||||
define_bench_task :allocations
|
define_bench_task :allocations
|
||||||
end
|
define_bench_task :thread_alone
|
||||||
# Load custom tasks
|
end# Load custom tasks
|
||||||
Dir['tasks/*.rake'].sort.each { |f| load f }
|
Dir['tasks/*.rake'].sort.each { |f| load f }
|
||||||
|
20
benchmark/thread_alone.rb
Normal file
20
benchmark/thread_alone.rb
Normal 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
|
Loading…
Reference in New Issue
Block a user