在Windows XP下,Ruby FTP非常慢 [英] Ruby FTP extremely slow under Windows XP
问题描述
几天前,我开发的一个更加复杂的Ruby应用程序开始运行非常缓慢。当我调查这个问题时,我将问题隔离到FTP命令。我现在重新运行原始测试脚本,并且需要两分钟分钟才能运行。命令行FTP本质上是即时的。
ruby目录结构中的文件没有改变。我不相信任何新的应用程序已经安装 - 当然没有其他应用程序似乎正在运行。
任何人都可以建议为什么下面的代码应该运行得这么慢吗?对 来自谷歌搜索: print
语句之间的间隔手动计时表明 ls
每个约需65秒!分析器为 nlst
提供了16个更合理的ms / call总数,31个为 ls
。
$ p $ require'net / ftp'
Net :: FTP.open(ip_redacted,user_redacted, password_redacted)do | ftp |
ftp.chdir(dir_redacted)
files = ftp.nlst
printfiles =#{files.sort!} \\\
list = ftp.ls
printlist =#{list} \\\
file =filename_redacted
size = ftp.size(file)
printsize =#{size} \\\
end
希望这有助于您。
A couple of weeks ago, I wrote a simple Ruby script to test a couple of FTP commands in a Windows XP environment. Everything worked as expected, and I wasn't even aware of the time taken for the code to run (I'd guess 3-4 seconds at the very most.)
A few days ago, a much more involved Ruby application I'm developing started running very slowly. As I investigated the issue, I isolated the problem to the FTP commands. I've now rerun the original test script, and it takes over two minutes to run. Command-line FTP is essentially instantaneous.
No files in the ruby directory structure have been changed. I do not believe any new applications have been installed - certainly no other applications appear to be running.
Can anyone suggest why the following code should run so slowly? Manually timing the intervals between print
statements suggest the nlst
and ls
take about 65 seconds each! The profiler gives a much more plausible total ms/call of 16 for nlst
and 31 for ls
.
require 'net/ftp'
Net::FTP.open("ip_redacted", "user_redacted", "password_redacted") do |ftp|
ftp.chdir("dir_redacted")
files = ftp.nlst
print "files = #{files.sort!}\n"
list = ftp.ls
print "list = #{list}\n"
file = "filename_redacted"
size = ftp.size(file)
print "size = #{size}\n"
end
From a google search:
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/112910
Hope this helps.
这篇关于在Windows XP下,Ruby FTP非常慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!