Hello Matt,
Can you perhaps look at the performance of SSH/SFTP? This is quick - no complaints about it:
std::auto_ptr<cksftpdir> dirListing(_sftp.ReadDir(handle)); if (dirListing.get()==0) return false;
But after that I loop over the results calling all kind of info-methods for the file/directory.
These are the calls I make (not really in this order and a lot of code removed, only showing the chilkat code without error checking)
long n = dirListing->get_NumFilesAndDirs(); for (int i = 0; i < n; i++) { std::auto_ptr<cksftpfile> fileObj(dirListing->GetFileObject(i)); fileObj->put_Utf8(true); if (p_hideSym && fileObj->get_IsSymLink()) if (fileObj->get_IsDirectory()) if (fileObj->get_IsRegular()) ient->_size = fileObj->get_Size64(); CString ux = directoryWeAreListing; if (ux.Right(1)!=L'/') ux += L'/'; ux += ient->_name; _sftp.GetFileCreateTime(UTF8(ux), true, false, systime); _sftp.GetFileLastModified(UTF8(ux), true, false, systime); }
I notice for large directory listings, the "ReadDir" is quick enough but the rest of the method seems quite slow. For one or two files this is not a problem, but I am working with directories with thousands of files (and maybe subdirectories).
I wonder if you hit the SFTP server for every (?) call I do in this loop. Or is it the GetFileXXXTime() calls? Can I in someway optimize this, OR CAN YOU?
Thanks for thinking with me, Gert
Gert,
The Chilkat.SFtp (CkSFtp) object contains the connection to the SSH server. The Chilkat.SFtpFile (CkSFtpFile) and Chilkat.SFtpDir (CkSFtpDir) objects to not have a connection. Therefore, all methods and properties of the CkSFtpFile and CkSFtpDir objects cannot possibly communicate with the server.
In your code snippet above, the calls to _sftp.GetFileCreateTime and _sftp.GetFileLastModified are sending a message to the server to retrieve the date/times for the path (or handle) specified. You should instead get the file date/time information directly from the fileObj (CkSFtpFile) either through the properties that return a "SYSTEMTIME" or via the methods that return a CkDateTime object.
Thanks,
I am not sure why I didnt do that in the first place.
Stupid me for calling GetFileCreateTime and GetFileLastModified. Now that I have switched to calling those methods on the CkSftpFile performance is great!
Thanks again.