Legal | Privacy
# trans_perf_test.rb: Performance test for transactions
require 'config.rb'

# Create a connection to Oracle
conn = OCI8.new(DB_USER, DB_PASSWORD, DB_SERVER)
conn.exec("DELETE FROM test_transaction")
conn.commit

# Commit on each time
conn.autocommit = true
time1 = Time.now
300.times{
	conn.exec("INSERT INTO test_transaction VALUES(1, 'something')")
}
time2 = Time.now

# Commit on the last step
conn.autocommit = false	# It's the default
time3 = Time.now
300.times{
	conn.exec("INSERT INTO test_transaction VALUES(1, 'something')")
}
conn.commit
time4 = Time.now

# Output the comparation
puts "Time cost of each-time commit(sec): " + (time2-time1).to_s
puts "Time cost of one-time commit(sec) : " + (time4-time3).to_s

conn.logoff

puts '-'*80
E-mail this page
Printer View Printer View
Oracle Is The Information Company About Oracle | Oracle RSS Feeds | Careers | Contact Us | Site Maps | Legal Notices | Terms of Use | Privacy