From: donghee yang Date: Mon, 8 Apr 2013 15:16:01 +0000 (+0900) Subject: [Title] Show the transfer rate for file-tranferring X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0b0883b20d52c4cd803ccb375019c917aea3a03a;p=sdk%2Ftools%2Fsdk-build.git [Title] Show the transfer rate for file-tranferring --- diff --git a/src/common/FileTransferViaDirect.rb b/src/common/FileTransferViaDirect.rb index 744c6f6..4f78222 100644 --- a/src/common/FileTransferViaDirect.rb +++ b/src/common/FileTransferViaDirect.rb @@ -64,6 +64,7 @@ class FileTransferDirect old_progress = 0 # read file contents # send via tcp/ip + trBegin = Time.now() File.open(src_file, "rb") do |io| while size > 0 buf = io.read(size > 1024*1024 ? 1024*1024 : size) @@ -77,8 +78,9 @@ class FileTransferDirect end end end - - @log.info "Upload is succeeded!" + trEnd = Time.now() + trRate = (full_size * 1000 / (trEnd - trBegin) / 1000).to_i + @log.info "Upload is succeeded! #{trRate}KByte/s" conn.puts "SEND_OK" # wait for download result @@ -114,12 +116,14 @@ class FileTransferDirect @log.info "Received file info from remote site" filename = tok[1].strip size = tok[2].strip.to_i + full_size = size checksum = tok[3].strip if File.directory? dst_file then dst_file = File.join(dst_file, filename) end + trBegin = Time.now() File.open( dst_file, "wb" ) do |io| while size > 0 buf = conn.read(size > 1024*1024 ? 1024*1024 : size) @@ -131,6 +135,9 @@ class FileTransferDirect size -= buf.length end end + trEnd = Time.now() + trRate = (full_size * 1000 / (trEnd - trBegin) / 1000).to_i + @log.info "Download is succeeded! #{trRate}KByte/s" conn.puts "RECEIVE_OK"