Guest User

Untitled

a guest
Aug 6th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1.  
  2. require 'active_record'
  3.  
  4. ActiveRecord::Base.establish_connection(
  5. :host => "ltwpeter-vm-w7",
  6. :adapter => "sqlserver",
  7. :mode => "odbc",
  8. :dsn => "ltwpeter_vm_w7",
  9. :username => "aw_web",
  10. :password => "aw_web8245",
  11. :database => "AdventureWorks"
  12. )
  13. SQL = ActiveRecord::Base
  14. start_time = nil
  15. begin
  16. start_time = Time.now
  17. puts "Starting ActiveRecord/SqlServer request"
  18. rows = SQL.connection.select_all("select count(column_name) as 'normal_count' from information_schema.columns")
  19. puts rows.inspect
  20.  
  21. puts "Now pausing VirtualBox VM... "
  22. puts %x/ VBoxManage controlvm "Windows 7" pause /
  23. sleep 1
  24. puts "Then execute the request again w/ Timeout.rb::timeout() ..."
  25. puts "Start time #{start_time}"
  26. timeout(5) do
  27. rows = SQL.connection.select_all("select count(column_name) as 'timeout_count' from information_schema.columns")
  28. puts rows.inspect
  29. end
  30.  
  31. rescue Timeout::Error => time_e
  32. puts time_e.inspect
  33. rescue Errno::ETIMEDOUT => etimeout
  34. puts etimeout.inspect
  35. rescue Exception => e
  36. puts e.inspect
  37. ensure
  38. puts "End time #{Time.now} "
  39. puts "Total time for SQL request: #{start_time.nil? ? "error" : Time.now - start_time} "
  40. sleep 1
  41. puts "Now resuming VirtualBox VM... "
  42. puts %x/ VBoxManage controlvm "Windows 7" resume /
  43. end
  44. # # Total time for reqeust to 192.168.12.12: 74.629005
Add Comment
Please, Sign In to add comment