Www.networkcomms.net Official forum to discuss the performance of Networkcomms V3, first record
I replaced the Streamtool.write implementation with a simple synchronous version:
Public Static DoubleWrite (Stream InputStream,LongInputstart,LongInputlength, Stream Destinationstream,intWritebuffersize,DoubleTimeoutmsperkbwrite,intMintimeoutms) { if(InputStream = =NULL)Throw NewArgumentNullException ("Source"); if(Destinationstream = =NULL)Throw NewArgumentNullException ("Destination"); //Make sure we startInputstream.seek (Inputstart, Seekorigin.begin); intBytesRemaining = (int) Inputlength; intBufSize = Math.min ((int) inputlength, writebuffersize); byte[] buf =New byte[BufSize]; while(BytesRemaining >0) { intcount; if(BytesRemaining <buf. Length) Count= (int) bytesremaining; ElseCount=buf. Length; Inputstream.read (BUF,0, Count); Destinationstream.write (BUF,0, Count); BytesRemaining-=count; } return 0; }
Now the performance is fine!
First I thought the allocation of the various buffers and objects in your implmenentation are the reason, but now I suppose It ' s due to the overhead of thread/context switching from the asynchronous stream begin/end methods.
Tested it with a slightly modified version of your Examplesconsole Advandedsend example which runs now five times faster.
Send calls per second increased from the 25000 on localhost and the CPU load dropped to one third.
Official forum to discuss the performance of Networkcomms V3, first record