Created
May 24, 2018 22:18
-
-
Save gipsh/d6be4d26a3b4d7b9439186eea5062fce to your computer and use it in GitHub Desktop.
ftp upload file benchmark test with threads
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
FTP_HOST = "ftp.pepe.com" | |
FTP_USER = "coco" | |
FTP_PASS = "coco" | |
# create>> dd if=/dev/zero of=output.file bs=1024 count=1024 | |
UPLOAD_FILE = File.new("./output.file") | |
def upload_file | |
file_time = Time.now.strftime("%Y%m%d%H%M%S%L") | |
file_name = "file_#{file_time}-#{Thread.current.object_id}-.xxx" | |
puts "Uploading: #{file_name} [size: #{UPLOAD_FILE.size}]" | |
puts Benchmark.measure { | |
Net::FTP.open(FTP_HOST, FTP_USER, FTP_PASS) do |ftp| | |
ftp.putbinaryfile(UPLOAD_FILE, file_name) | |
end | |
} | |
end | |
threads = [] | |
130.times { | |
threads << Thread.new { upload_file } | |
} | |
threads.each { |thr| thr.join } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment