none
Function call taking time to return values RRS feed

  • Question

  • I have a function residing in a class library. On profiling, I saw that it takes  about 150 microseconds to complete its task. But by the time the value is returned to the caller, I see that total time taken goes to 3 milliseconds - a 20 times increase. To clarify further, from the calling application, the function call timing shows 3 milliseconds. But within the function it shows 150 microseconds till the line which says Return. The caller and the class library are in two separate DLLs. The function is a Public Shared function and the value returned is a string. The numbers seem small but since the function is called in a loop the effect is magnified. Any idea why this may be happening?

    Thanks,
    Girish

    Friday, October 16, 2009 1:49 AM

Answers

  • Hello Yort,

    Thanks for your response. Just disovered that the issue is with a call to Double.NaN.ToString. It is slowing the code by orders of magnitude. It was outside the profiled code. Removing the ToString boosted the code. The above issue can be treated as closed. I will look into this Double.NaN.ToString thing and start a new thread if required.

    Thanks,
    Girish
    • Marked as answer by Girish Bhat Friday, October 16, 2009 3:38 AM
    Friday, October 16, 2009 3:37 AM

All replies

  • Hi,

    How large is the data being returned (how big is the string)  ? Is the library being accessed via COM, Remoting, WCF, a web service etc ? Are any values being explcitily passed as by ref, by val or out ? Are the inputs (parameters) passed to the function being returned from nested function calls ? What kind/size of data are the parameters ?

    I think we need a little more info to diagnose the problem.

    Friday, October 16, 2009 2:26 AM
  • Hello Yort,

    Thanks for your response. Just disovered that the issue is with a call to Double.NaN.ToString. It is slowing the code by orders of magnitude. It was outside the profiled code. Removing the ToString boosted the code. The above issue can be treated as closed. I will look into this Double.NaN.ToString thing and start a new thread if required.

    Thanks,
    Girish
    • Marked as answer by Girish Bhat Friday, October 16, 2009 3:38 AM
    Friday, October 16, 2009 3:37 AM
  • No problem, glad you found the answer :)
    Friday, October 16, 2009 3:39 AM