-
-
Save pietia/229449 to your computer and use it in GitHub Desktop.
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
require 'benchmark' | |
require 'rubygems' | |
require 'addressable/uri' | |
require 'pathname' | |
include Benchmark | |
dir = File.dirname(__FILE__) | |
lib_path = File.expand_path("#{dir}/lib") | |
$LOAD_PATH.unshift lib_path unless $LOAD_PATH.include?(lib_path) | |
# put data_objects from repository in the load path | |
# DO NOT USE installed gem of data_objects! | |
do_lib_path = File.expand_path("#{dir}/../data_objects/lib") | |
$LOAD_PATH.unshift do_lib_path unless $LOAD_PATH.include?(do_lib_path) | |
jdbc_lib_path = File.expand_path(File.join(File.dirname(__FILE__), '..', 'do_jdbc', 'lib')) | |
$LOAD_PATH.unshift jdbc_lib_path unless $LOAD_PATH.include?(jdbc_lib_path) | |
require 'do_jdbc' | |
require 'data_objects' | |
DATAOBJECTS_SPEC_ROOT = Pathname(__FILE__).dirname.parent.parent + 'data_objects' + 'spec' | |
Pathname.glob((DATAOBJECTS_SPEC_ROOT + 'lib/**/*.rb').to_s).each { |f| require f } | |
require 'do_h2' | |
ITER = 100000 | |
bm(12) do |test| | |
conn = DataObjects::Connection.new("jdbc:h2:mem") | |
test.report("Open, move and close reader") do | |
ITER.times do |t| | |
reader = conn.create_command("SELECT code, name FROM widgets WHERE ad_description = ? order by id").execute_reader('Buy this product now!') | |
reader.next! | |
y = reader.values | |
reader.close | |
end | |
end | |
test.report("Reader#field_count") do | |
ITER.times do |t| | |
reader = conn.create_command("SELECT code, name FROM widgets WHERE ad_description = ? order by id").execute_reader('Buy this product now!') | |
z = reader.field_count | |
reader.close | |
end | |
end | |
test.report("Reader#fields") do | |
ITER.times do |t| | |
reader = conn.create_command("SELECT code, name FROM widgets WHERE ad_description = ? order by id").execute_reader('Buy this product now!') | |
q = reader.fields | |
reader.close | |
end | |
end | |
end |
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
e6ff922 | |
------- | |
user system total real | |
Open, move and close reader 3.802000 0.000000 3.802000 ( 3.803000) | |
Reader#field_count 3.230000 0.000000 3.230000 ( 3.230000) | |
Reader#fields 3.220000 0.000000 3.220000 ( 3.220000) | |
user system total real | |
Open, move and close reader 3.791000 0.000000 3.791000 ( 3.791000) | |
Reader#field_count 3.219000 0.000000 3.219000 ( 3.219000) | |
Reader#fields 3.210000 0.000000 3.210000 ( 3.210000) | |
user system total real | |
Open, move and close reader 3.777000 0.000000 3.777000 ( 3.777000) | |
Reader#field_count 3.237000 0.000000 3.237000 ( 3.237000) | |
Reader#fields 3.244000 0.000000 3.244000 ( 3.244000) | |
cfe59f4 | |
------- | |
user system total real | |
Open, move and close reader 4.165000 0.000000 4.165000 ( 4.165000) | |
Reader#field_count 3.610000 0.000000 3.610000 ( 3.611000) | |
Reader#fields 3.641000 0.000000 3.641000 ( 3.641000) | |
Open, move and close reader 4.145000 0.000000 4.145000 ( 4.146000) | |
Reader#field_count 3.581000 0.000000 3.581000 ( 3.581000) | |
Reader#fields 3.592000 0.000000 3.592000 ( 3.593000) | |
user system total real | |
Open, move and close reader 4.166000 0.000000 4.166000 ( 4.166000) | |
Reader#field_count 3.597000 0.000000 3.597000 ( 3.597000) | |
Reader#fields 3.633000 0.000000 3.633000 ( 3.633000) | |
cb6dc70 | |
------- | |
user system total real | |
Open, move and close reader 4.223000 0.000000 4.223000 ( 4.223000) | |
Reader#field_count 3.670000 0.000000 3.670000 ( 3.670000) | |
Reader#fields 3.747000 0.000000 3.747000 ( 3.747000) | |
user system total real | |
Open, move and close reader 4.144000 0.000000 4.144000 ( 4.144000) | |
Reader#field_count 3.607000 0.000000 3.607000 ( 3.607000) | |
Reader#fields 3.645000 0.000000 3.645000 ( 3.645000) | |
Open, move and close reader 4.216000 0.000000 4.216000 ( 4.216000) | |
Reader#field_count 3.680000 0.000000 3.680000 ( 3.680000) | |
Reader#fields 3.668000 0.000000 3.668000 ( 3.668000) |
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
e6ff922 (ivars) | |
------- | |
user system total real | |
Open, move and close reader 38.439000 0.000000 38.439000 ( 38.439000) | |
Reader#field_count 35.685000 0.000000 35.685000 ( 35.685000) | |
Reader#fields 35.142000 0.000000 35.142000 ( 35.142000) | |
8617aae (before mkristian's latest refactorings) | |
------- | |
user system total real | |
Open, move and close reader 38.970000 0.000000 38.970000 ( 38.971000) | |
Reader#field_count 36.931000 0.000000 36.931000 ( 36.931000) | |
Reader#fields 37.936000 0.000000 37.936000 ( 37.936000) | |
after | |
----- | |
user system total real | |
Open, move and close reader 37.764000 0.000000 37.764000 ( 37.764000) | |
Reader#field_count 36.625000 0.000000 36.625000 ( 36.625000) | |
Reader#fields 37.067000 0.000000 37.067000 ( 37.067000) |
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
jruby --server do-jdbc-reader-benchmark.rb (--server mode) | |
user system total real | |
Open, move and close reader 26.184000 0.000000 26.184000 ( 26.184000) | |
Reader#field_count 20.658000 0.000000 20.658000 ( 20.658000) | |
Reader#fields 21.217000 0.000000 21.217000 ( 21.217000) | |
jruby do-jdbc-reader-benchmark.rb (--client mode) | |
-------------------------------------------------- | |
Open, move and close reader 41.294000 0.000000 41.294000 ( 41.294000) | |
Reader#field_count 39.075000 0.000000 39.075000 ( 39.075000) | |
Reader#fields 39.854000 0.000000 39.854000 ( 39.854000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment