Uploaded image for project: 'Commons Net'
  1. Commons Net
  2. NET-455

FTPClient listFiles(FTPFileFilter) can be faster...

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Not A Problem
    • 3.0.1
    • None
    • FTP
    • all

    Description

      I tested two ways of sorting files on a remote FTP server with many files ( > 110 000). Both of these use the FtpFileFilter class (with a test on the extension filename... very simple).

      The first one is the conventionnal =>

      files = ftpClient.listFiles("./", ftpFileFilter);
      

      It takes about 90 seconds ...

      the second one is ... nearly as simple as the first one :

      FTPFile []  allFilesListed = ftpClient.listFiles();
      files = FTPFileFilterWithExtension.fastFilter(ftpFileFilter, allFilesListed);
      

      The function FTPFileFilterWithExtension.fastFilter() call the same ftpFileFilter :

      public static FTPFile [] fastFilter(FTPFileFilter filter, FTPFile ftpFileArray []) {
          ArrayList<FTPFile> listOfFTPFiles = new ArrayList<FTPFile>();
          for (FTPFile ftpf : ftpFileArray) {
              boolean accepted = filter.accept(ftpf);
              if (accepted) {
                  listOfFTPFiles.add(ftpf);
              }
          }
          FTPFile resultArray [] = new FTPFile[listOfFTPFiles.size()];
          return listOfFTPFiles.toArray(resultArray);
      }
      

      The second method is EIGHT times faster than the first one ... and I don't really understand why...

      Attachments

        Activity

          People

            Unassigned Unassigned
            slash666 Nicolas
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 1h
                1h
                Remaining:
                Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified