Guest User

Untitled

a guest
Dec 25th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. require 'benchmark'
  2. require 'net/ssh'
  3.  
  4. count = 15
  5. user = 'manu'
  6. host = 'xx.xx.xxx.xxx'
  7. port = '22'
  8. password = 'pass'
  9.  
  10. Benchmark.bm do |bm|
  11. bm.report('Close session') do
  12. count.times do
  13. session = Net::SSH.start(host, user, password: password, port: port)
  14. session.exec!('hostname')
  15. session.close
  16. end
  17. end
  18.  
  19. bm.report('Reuse session') do
  20. session = Net::SSH.start(host, user, password: password, port: port)
  21. count.times do
  22. session.exec!('hostname')
  23. end
  24. session.close
  25. end
  26. end
  27.  
  28. ###
  29. #
  30. # user system total real
  31. # close session 1.890000 0.260000 2.150000 ( 27.267397)
  32. # reuse session 0.140000 0.040000 0.180000 ( 6.670353)
Add Comment
Please, Sign In to add comment