Skip to content

Instantly share code, notes, and snippets.

@jfirebaugh
Created November 4, 2011 00:13
Show Gist options
  • Select an option

  • Save jfirebaugh/1338323 to your computer and use it in GitHub Desktop.

Select an option

Save jfirebaugh/1338323 to your computer and use it in GitHub Desktop.
$LOAD_PATH << "lib"
require 'benchmark'
require 'sequel'
require 'sequel/adapters/jdbc'
ds = Sequel::JDBC::Dataset.new(Sequel::JDBC::Database.new({}))
Benchmark.bm(10) do |x|
x.report("timestamp") { 100000.times { ds.send(:convert_type, Java::JavaSQL::Timestamp.new(0)) } }
x.report("nil") { 100000.times { ds.send(:convert_type, nil) } }
end
Before:
user system total real
timestamp 19.301000 0.000000 19.301000 ( 19.281000)
nil 2.459000 0.000000 2.459000 ( 2.459000)
After:
user system total real
timestamp 2.447000 0.000000 2.447000 ( 2.429000)
nil 0.088000 0.000000 0.088000 ( 0.088000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment