Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'benchmark'
- require 'net/ssh'
- count = 15
- user = 'manu'
- host = 'xx.xx.xxx.xxx'
- port = '22'
- password = 'pass'
- Benchmark.bm do |bm|
- bm.report('Close session') do
- count.times do
- session = Net::SSH.start(host, user, password: password, port: port)
- session.exec!('hostname')
- session.close
- end
- end
- bm.report('Reuse session') do
- session = Net::SSH.start(host, user, password: password, port: port)
- count.times do
- session.exec!('hostname')
- end
- session.close
- end
- end
- ###
- #
- # user system total real
- # close session 1.890000 0.260000 2.150000 ( 27.267397)
- # reuse session 0.140000 0.040000 0.180000 ( 6.670353)
Add Comment
Please, Sign In to add comment