Created
November 17, 2010 20:04
-
-
Save sgoings/703966 to your computer and use it in GitHub Desktop.
Rspec Tests for SCP upload transfer performance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/scp' | |
describe Net::SCP do | |
def analyze(filename) | |
file_size = (File.size(filename)/(1024*1024)) | |
puts "Starting transfer of #{filename}" | |
start_time = Time.now | |
yield filename | |
duration = Time.now - start_time | |
puts "Finished transfer of #{filename}" | |
puts "--> Duration: #{duration} seconds (#{(file_size)/duration} megabytes/s)" | |
end | |
before(:all) do | |
hostname = "9.17.164.151" | |
user = "root" | |
password = "passw0rd" | |
@scp = Net::SCP.start(hostname, user, {:password => password}) | |
@scp2 = Net::SCP.start(hostname, user, {:password => password}) | |
puts "Done creating channels" | |
@filename = "/home/seth/afpcases/systeme.afp" | |
@remote_path = "/home/seth" | |
@remote_path2 = "/home/seth/test" | |
end | |
it "should show transfer speed of serial uploads" do | |
analyze(@filename) do | |
|file| | |
@scp.upload!(file, @remote_path) | |
@scp.upload!(file, @remote_path2) | |
end | |
end | |
it "should show transfer speed of simultaneous async channels" do | |
channels = [] | |
analyze(@filename) do | |
|file| | |
channels << @scp.upload(file, @remote_path) | |
channels << @scp.upload(file, @remote_path2) | |
channels.each { |ch| ch.wait } | |
end | |
end | |
it "should show transfer speed of simultaneous SCP instances" do | |
channels = [] | |
analyze(@filename) do | |
|file| | |
channels << @scp.upload(file, @remote_path) | |
channels << @scp2.upload(file, @remote_path2) | |
channels.each { |ch| ch.wait } | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment