none
Injecting the Helper function call with a Condition ? RRS feed

  • Question

  • Hi,

    I have a severe problem now. I need to handle the case where in a web request, few functions are being called more than a million times added together. 

    SomeDotNetFunction()
    {
    //HelperFunc Enter Call
    ..
    ..
    //helper Func Exit Call
    }

    The helper functions will again call the C++ functions to log. 

    As my profiler injects two helper functions (one at entry and one for exit) there will be double the number of helper function calls that will again call my native function.

    In such cases I am getting a massive overhead .

    Is there any possible way to tell the SomeDotNetFunction() Not to call the helper functions when it's calls exceeds more than thousand..? 

    I tried maintaining a map to count the number of function calls in both C++ and C#. Neither of the approaches works. It caused overhead only. I am sure that some one would have faced this similar case. 

    I hope for a best solution.

    ./Selva

    Tuesday, June 16, 2015 12:20 PM

Answers

  • Hi Selva,

    After some research,I am sorry I don't find any direct settings or attribute to restrict the called times of a function. But based on your description,  from my personal perspective,you could try these two suggestions as below

    1. Using a static variable to record the function call times.
    static int i=0;
       SomeDotNetFunction()
       {
         if(i<= 1000)
         {
         //HelperFunc Enter Call
         i++;
         }
         ......
         if(i<= 1000)
         {
         //HelperFunc exit Call
         i++;
         }
       }  

          2. Or you can check the log of  Helper function generated, based on the log count or other key flag, you can determine how many times the function called 

    Have a nice day!

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Wednesday, June 17, 2015 7:31 AM