Last post May 15, 2015 04:26 PM by PatriceSc
May 14, 2015 02:44 AM|vsselvaraj|LINK
I am developing a profiler for .net web requests.
In my helper function ( C#) , I need to assign and store the guid for each request.
So I was storing in the context items as - "HttpContext.Current.Items["GUID"]" by cheching if HttpContext.Current is not 'null' . So that i can access it from any other static functions inside the same request.
But i found that accessing the HttpContext current object is causing more overhead upto 50% for a million calls.
Is there any other way to store the GUID which can be accessed through out the request ?
Thanks & Regards,
May 15, 2015 03:32 AM|Krunal Parekh|LINK
You could try putting it in Request Headers. But I am not sure but its impact on overhead. see
Also there is no concept like Request ID here so you will need to generate your guid and store it in the request.
Hope this helps.
May 15, 2015 08:17 AM|vsselvaraj|LINK
Thanks for ur reply.! But can this be assigned inside a static function? How to do that.?
Should i use some thing like "HttpContext.Current.Request.Headers" ?? If so above this line i need to check if "HttpContext.Current" is null or not, where a issue exists. The check if it is null or not itself is causing more overhead.
May 15, 2015 04:26 PM|PatriceSc|LINK
What is your test? Could it be that you compared doing this null check millions of time for a single request (you'll never do actually that) compared with doing nothing at all? Yes, you'll always find that doing something is slower than doing nothing (I
saw once someone suggesting to avoid function calls based on such a finding). Also beware of percentage. The actual time does matter.
My guess for now is that what you found is just not significant and doesn't need to be fixed.