diff --git a/Rakefile b/Rakefile index ad0a387..60fb02a 100644 --- a/Rakefile +++ b/Rakefile @@ -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 } diff --git a/benchmark/thread_alone.rb b/benchmark/thread_alone.rb new file mode 100644 index 0000000..c6b4c1e --- /dev/null +++ b/benchmark/thread_alone.rb @@ -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 \ No newline at end of file