views:

240

answers:

1

I'm using Response.TransmitFile to retrieve a file from a web service. I'd like to measure the amount of time this process takes from the server's perspective.

I've tried grabbing the tick count before and after this call, but that clearly didn't represent how long the transfer took. It gave me back numbers like 0.0016 milliseconds for a 30 MB file. :-)

Any ideas?

+2  A: 

The transfer is asynchronous, as you've seen.

You may be able to get what you want by turning off buffering in the HttpResponse (Response.Buffer = false) before calling TransmitFile. If that fails, then transmit it "manually" and synchronously, using FileStream.

If you only want to observe the time required for the transmission, just for your information, and don't need to log the time in your application, you can do it with Fiddler.

Cheeso
AFAIK, TransmitFile hands off the transfer to IIS/Kernel for much higher performance, so moving away from it will incur a significant performance penalty on the server side. Fiddler is a good suggestion from the client side.There may be a way to enable IIS logging or other features to benchmark the TransmitFile API.
EricLaw -MSFT-
Does the response.buffering attribute affect the TransmitFile call? According to MSDN "[TransmitFile] writes the specified file directly to an HTTP response output stream without buffering it in memory."
JohnFx