1

我的应用程序在前端和数据库之间有一个 WCF 服务层。由于我们目前托管在 IIS6 中,因此我们使用的是 SOAP over HTTP。我如何才能知道在我的应用程序中进行序列化活动所花费的实际时间是多少?

4

4 回答 4

4

不是关于测量——而是关于改进:我一直在研究protobuf-net,它是用于 .NET 的 Google 的“协议缓冲区”(一种紧凑的、低 CPU 二进制序列化格式)的实现——包括一个 WCF 挂钩(用于替换DataContractSerializer)。它有一些非常好的指标重新序列化。

当与基本的 http 绑定一起使用时,它也可以与 MTOM 一起使用,因此您甚至不会获得二进制的 base-64 开销。这里有一个 WCF 示例。

可能很有意思……

于 2008-11-02T10:08:07.050 回答
1

Create a message inspector and add it to your endpoint behavior,

In the message inspector, you implement the interface which has the following method

AfterReceiveRequest
{
  DateTime start = datetime.now;
  return start;
}
BeforeSendReply
{
 // start will be passed in as state in the parameter.  
 TimeSpan period = datetime.now - start 
}
于 2008-11-02T06:28:33.590 回答
0

One of the dead simple things old mainframes always used to to was to include a "sever time" field in the response. Therefore you'd know that anything that happened between your observed time and server time is network/serialization overhead. I know it kind of 1960-ish, but it still works well.

If you want avoid changing the method signature you can set it in a http response header or something ;)

于 2008-11-02T06:23:25.223 回答
0

The xperf tools are a good choice if you can run on Windows Server 2008 and Vista on the client. These are ETW based and use the Windows sample profile interrupt to profile anything running on the system. Here is series of posts on the xperf tools from myself. This post is specifically about profiling.

note that you can download the latest version of the tools directly for this page.

You may want to experiment with some of the other kernel events, such as disk IO and hard faults.

于 2008-11-02T06:31:52.540 回答