使用Visual Studio Profiler测试host在本地IIS上的WCF服务性能

http://www.cnblogs.com/telnet_mike/archive/2011/11/07/2240351.html

读过上篇bolg的现在应该知道怎么样来Profile一个WCF项目了,今天我们来看一下怎样Profile一个host到本地IIS上的WCF服务,我们还是使用Visual Studio 2010还有上篇blog中的测试项目。

使用Administrator账户启动Visual Studio 2010!

How to: Host a WCF Service in IIS

Deploying an Internet Information Services-Hosted WCF Service

Using Visual Studio 2010 to Host a WCF Service on the Local IIS Instance

Open or create a WCF Service Application project. Right click the project in the solution explorer and select Properties. In the project properties window select the Web tab on the left hand side of the window. On the right hand side of the window, under Servers, select the Use Local IIS Web Server and type in a URL. Next, click the Create Virtual Directory button and build the solution. This will create the virtual directory in IIS and map it to your project directory. The service will then be hosted on the local IIS server for building and debugging purposes. To verify the service has been hosted, open Internet Explorer and type the service’s URL in the address box. You must type in the complete URL path to the .svc file. For example, with a default WCF Service Application project hosted under http://localhost/MyFirstService the complete URL would be http://localhost/MyFirstService/Service1.svc. This will display the default WCF Service page.

hostWCF2LocalIIS

使用同样的步骤将我们的WebApplication1 asp.net应用程序项目也host到本地IIS上。

WcfService1地址: http://localhost/WcfService1/Service1.svc

WebApplication1地址: http://localhost/WebApplication1

proformancewizard1_4

proformancewizard2_4

proformancewizard3_4

proformancewizard4_4

IE会直接打开WCF服务的页面:

WcfService1

现在我们可以用WebApplication1地址来替换WcfService1地址,并让IE浏览它,这样我们可以使用我们的asp.net应用来调用WcfService1中的函数,从而达到测试性能的目标。

testpage

报表会在你关闭IE的时候,Visual Studio Profiler工具停止后,自动打开。

report1

你可以看到所有的函数调用,但你点击WcfService1.Service1.Abc(int32)函数后,它会为你打开一个详细页面和你的函数源代码。

sourcecode

My English Blog: http://mikedoszhang.blogspot.com/2011/11/profile-wcf-which-hosted-in-local-iis.html

posted @ 2011-11-09 14:43  Mike Dos Zhang  阅读(1095)  评论(0编辑  收藏  举报