سؤال

We are looking at some performance issues with a web service we are calling. I have managed to place time recording code throughout the actual webservice methods itself, but now it's looking as if the actual time it takes to serialize the result set could be an issue?

So am looking to record how long serializing this data is taking, but am struggling to get any results..

Here is an example web service method we have:

[AuthExtension]
[WebMethod]
[SoapHeader("AuthHeader", Direction = SoapHeaderDirection.In)]
public ResultSet CheckAvailability(FareSelections fareSelections)
{
    ResultSet results = null;
    results = Logic.CheckAvailability(fareSelections, AuthHeader.Token, timeLogger);
    return results;
}

I have tried, placing methods in the class being returned that are decorated with [OnSerializing()] and [OnSerialized()] attributes, but this doesn't work. I have also tried to capture timings in the method by making use of a try..finally block, but don't think this is recording the actual serialization time either?

It has been suggested that I may have to implement my own serializer (which would simply record timings and then call the default serializer anyway), but was just wondering if this was the only option I have?

Any thoughts very much appreciated.

هل كانت مفيدة؟

المحلول

You could use a Custom SoapExtension. In the ProcessMessage() method, you can see 4 events, Before and After serialization and Before and After deserialization. Start a stopwatch in the Befores, end it on the Afters, then store the time away somewhere.

نصائح أخرى

warp the call around a Stopwatch object

from memory:

  Stopwatch sw = Stopwatch.Startnew();
  //stuff
  sw.Stop();
  print sw.ElapsedMilliseconds();

Couldnt you use the service trace viewer to check to see how long each request is taking?

You should use something like Ants profiler (an eval version would do) to profile those methods in question.. it will give you a very good insight.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top