Ruby FTP is extremely slow under Windows XP

A few weeks ago, I wrote a simple Ruby script to test a couple of FTP commands in Windows XP. Everything worked as expected, and I did not even know about the time taken to run the code (I would prefer 3-4 seconds in the worst case.)

A few days ago, the much more active Ruby application that I am developing started very slowly. When I investigated the problem, I highlighted the problem for FTP commands. Now I have restarted the original test script, and it takes more than two minutes to run it. The command line flag is essentially instantaneous.

No files in the ruby ​​directory structure have been changed. I do not believe that any new applications have been installed - of course, no other applications work.

Can anyone suggest why the following code should work so slowly? Manually synchronizing the intervals between the operators printshow that nlstthey lstake about 65 seconds each! The profiler gives a much more plausible total ms / call of 16 for nlstand 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
+3
source share
3 answers

I had a similar problem, and in passive mode the speed increased, for example. ftp.passive=true.

+2
source

#sort! ( puts "files = #{files}"), , . #nlst #ls

0

Source: https://habr.com/ru/post/1708506/


All Articles