This project is read-only.

Slow Performance .... help!!

Feb 14, 2014 at 10:05 PM
I have a very simple proof of concept app that is using the SSH.NET library, but it is very slow when trying to download a file. I am connecting via sftp and only getting about 100KB instead of 1,000KB. If I use winSCP or any desktop app, I can download at 1,000KB.

Here is my code, any help would appreciated.
var connectionInfo = new PasswordConnectionInfo("host", "username", "password");
var encoding = new ASCIIEncoding();

using (var client = new SshClient(connectionInfo))
{
client.Connect();

client.DownloadFile("/largefile.txt", new FileStream(@"C:\largefile.txt", FileMode.Create, FileAccess.Write), null);

client.Disconnect();
}
Feb 15, 2014 at 11:25 AM
How you measure the performance?
Feb 15, 2014 at 7:30 PM
OK. Since your code won't compile (SshClient has no DownloadFile), I wrote some code for pseudo measurement myself:
        private static void DownloadFile(string ip, string user, string password, string file)
        {
            using (var client = new SftpClient(ip, user, password))
            {
                client.Connect();
                var filestream = new FileStream("bla", FileMode.OpenOrCreate);
                var start = DateTime.Now;
                client.DownloadFile(file, filestream);
                var end = DateTime.Now;

                var timespan = TimeSpan.FromSeconds((end - start).TotalSeconds);
                var size = (new FileInfo("bla").Length / 1024) / 1024;

                Console.WriteLine("{0} {1}", timespan.TotalSeconds , size);

                var speed = size/timespan.TotalSeconds;

                Console.WriteLine("Speed: {0} MB/s", speed);
            }
        }
(I know this code is not very good for performance measurements ;))

I get around 4-5 MB/s while downloading a 100MB file or a 1GB file
My bottleneck is my not so fast linux nas ^^

Btw, why is nobody able to paste his real code? That is quite frustrating..
Feb 17, 2014 at 1:43 PM
As mentioned in my previous post. "I am connecting via sftp and only getting about 100KB instead of 1,000KB"
Feb 17, 2014 at 3:00 PM
Edited Feb 17, 2014 at 3:07 PM
jhoop2002 wrote:
As mentioned in my previous post. "I am connecting via sftp and only getting about 100KB instead of 1,000KB"
whao...

You want help? Then give us your code where you measure the performance and some more useful information.
Else... i'm out...
Mar 7, 2014 at 1:06 PM
da_rinkes wrote:
jhoop2002 wrote:
As mentioned in my previous post. "I am connecting via sftp and only getting about 100KB instead of 1,000KB"
whao...

You want help? Then give us your code where you measure the performance and some more useful information.
Else... i'm out...
Hello, try to compare speed with winscp and you will see the differece...
pq