none
Spike in time requierd for method call in communicating with WCF Service

    Question

  • Hi!

    Here is my environment:

    WCF Service hosted in Windows Service - all the methods in WCF Service are just skeletons; they doesn't do ANYTHING right now, for example
    bool DoSomething() {
       return true;
    }
    WCF Client - WCF custom client developed by using files generated using svcutil (SDK 6A)
    Protocols:
    For Service contract - nettcpbinding
    For MEX - wsHttpBinding

    Both service and client  are/will be on the SAME machine

    When I call methods from WCF Client in a tight loop (I am testing with 10,000 calls), for most calls time taken is 0 ms. But, after every 15/20 calls, it takes around 15-20 ms. And since service isn't doing anything, my guess is that it is time required _just_ for method call/communication.

    I have also done this for WCFWindowsServiceSample example and it has same issue.

    When I was using wsHttpBinding for service contract frequency of spike in method call time was much more as expected.

    I am using System.Environment.Tickcount and although it may not be very accurate in determining CPU time, I am interested in total time taken so it should be okay (?)

    Has anyone come across this issue? And is there a resolution to it?

    If no one has come across this issue, do you have any thoughts on why and how it can be resolved?

    Thanks in advance,
    -Neel.
    • Edited by Neel__ Thursday, March 11, 2010 3:57 PM better title
    Thursday, March 11, 2010 3:56 PM

Answers

  • Hi Neel,

    I can reproduce this issue, I think it's caused by inaccuracy of Environment.Tickcount. We could use DateTime.Now.Ticks to get more accurate time(100 nanosecond internal). When I use datetime to measure time, the spike time gone, average time per call is 2-3ms.

    Thanks,
    Mog Liang
    • Marked as answer by Mog Liang Thursday, March 18, 2010 2:04 AM
    Monday, March 15, 2010 5:06 AM

All replies

  • Hi Neel,

    I can reproduce this issue, I think it's caused by inaccuracy of Environment.Tickcount. We could use DateTime.Now.Ticks to get more accurate time(100 nanosecond internal). When I use datetime to measure time, the spike time gone, average time per call is 2-3ms.

    Thanks,
    Mog Liang
    • Marked as answer by Mog Liang Thursday, March 18, 2010 2:04 AM
    Monday, March 15, 2010 5:06 AM
  • Hi Neel,

    I can reproduce this issue, I think it's caused by inaccuracy of Environment.Tickcount. We could use DateTime.Now.Ticks to get more accurate time(100 nanosecond internal). When I use datetime to measure time, the spike time gone, average time per call is 2-3ms.

    Thanks,
    Mog Liang

    Now I'll take a try on your way, Thanks for your help!
    Friday, October 01, 2010 3:43 AM