在Windows XP下,Ruby FTP非常慢 [英] Ruby FTP extremely slow under Windows XP

查看:117
本文介绍了在Windows XP下,Ruby FTP非常慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几周前,我编写了一个简单的Ruby脚本来测试Windows XP环境中的几个FTP命令。一切都按预期工作,我甚至都没有意识到代码运行所花的时间(我猜想最多只需3-4秒。)



几天前,我开发的一个更加复杂的Ruby应用程序开始运行非常缓慢。当我调查这个问题时,我将问题隔离到FTP命令。我现在重新运行原始测试脚本,并且需要两分钟分钟才能运行。命令行FTP本质上是即时的。



ruby​​目录结构中的文件没有改变。我不相信任何新的应用程序已经安装 - 当然没有其他应用程序似乎正在运行。

任何人都可以建议为什么下面的代码应该运行得这么慢吗?对 print 语句之间的间隔手动计时表明 nlst 和 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


解决方案

来自谷歌搜索:

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/112910



希望这有助于您。


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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆