Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'active_record'
- ActiveRecord::Base.establish_connection(
- :host => "ltwpeter-vm-w7",
- :adapter => "sqlserver",
- :mode => "odbc",
- :dsn => "ltwpeter_vm_w7",
- :username => "aw_web",
- :password => "aw_web8245",
- :database => "AdventureWorks"
- )
- SQL = ActiveRecord::Base
- start_time = nil
- begin
- start_time = Time.now
- puts "Starting ActiveRecord/SqlServer request"
- rows = SQL.connection.select_all("select count(column_name) as 'normal_count' from information_schema.columns")
- puts rows.inspect
- puts "Now pausing VirtualBox VM... "
- puts %x/ VBoxManage controlvm "Windows 7" pause /
- sleep 1
- puts "Then execute the request again w/ Timeout.rb::timeout() ..."
- puts "Start time #{start_time}"
- timeout(5) do
- rows = SQL.connection.select_all("select count(column_name) as 'timeout_count' from information_schema.columns")
- puts rows.inspect
- end
- rescue Timeout::Error => time_e
- puts time_e.inspect
- rescue Errno::ETIMEDOUT => etimeout
- puts etimeout.inspect
- rescue Exception => e
- puts e.inspect
- ensure
- puts "End time #{Time.now} "
- puts "Total time for SQL request: #{start_time.nil? ? "error" : Time.now - start_time} "
- sleep 1
- puts "Now resuming VirtualBox VM... "
- puts %x/ VBoxManage controlvm "Windows 7" resume /
- end
- # # Total time for reqeust to 192.168.12.12: 74.629005
Add Comment
Please, Sign In to add comment