<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>进化的测试 &#187; 性能测试</title>
	<atom:link href="http://magustest.com/blog/category/loadtest/feed/" rel="self" type="application/rss+xml" />
	<link>http://magustest.com/blog</link>
	<description>软件测试，自动化测试，白盒测试，Python</description>
	<lastBuildDate>Wed, 04 Jan 2012 09:09:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>VSTS 2010 Test Edition文章收集</title>
		<link>http://magustest.com/blog/softwaretesting/vsts2010-test-edition-article-collection/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=vsts2010-test-edition-article-collection</link>
		<comments>http://magustest.com/blog/softwaretesting/vsts2010-test-edition-article-collection/#comments</comments>
		<pubDate>Thu, 21 May 2009 01:45:38 +0000</pubDate>
		<dc:creator>magus</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[性能测试]]></category>
		<category><![CDATA[软件测试]]></category>
		<category><![CDATA[CodedUI Test]]></category>
		<category><![CDATA[VSTS]]></category>

		<guid isPermaLink="false">http://magustest.com/blog/?p=495</guid>
		<description><![CDATA[STS 2010 BETA 1在近期已经开始发布了，各路高手纷纷出动，在这里我就把我看到的一些不错的关于VSTS2010测试人员版本的文章收集一下，希望对其他人有帮助，也便于我以后复习用 文章： 《Automated User Interface Testing with Coded UI Test》VSTT官方博客出品，Coded UI Test入门 《VSTS 2010 Load Test Feature: Saving Test Logs》如何在VS的负载测试中记录日志，帮助定位问题 《VSTS 2010 Feature: Load test virtual user activity visualization》如果在用VSTS进行性能测试进行的过程中，CPU突然有一个不寻常的峰值出现，在以前是比较难找到原因的，此文给我们介绍了VSTS 2010的最新功能virtual user activity visualization 是如何帮助测试工程师找到问题的根源 《VSTS 2010 Feature: Web Test Recorder Plugins》如何在VSTS 2010中利用Web Test Recorder Plugins来做自定义的关联 《VSTS 2010: Enabling Test Impact Analysis》文章介绍了如何使用Test Impact <a href='http://magustest.com/blog/softwaretesting/vsts2010-test-edition-article-collection/'>[...]</a>
No related posts.]]></description>
			<content:encoded><![CDATA[<p>STS 2010 BETA 1在近期已经开始发布了，各路高手纷纷出动，在这里我就把我看到的一些不错的关于VSTS2010测试人员版本的文章收集一下，希望对其他人有帮助，也便于我以后复习用 <img src='http://magustest.com/blog/wp-includes/images/smilies/icon_lol.gif' alt=':lol:' class='wp-smiley' /> </p>
<p><strong>文章：</strong></p>
<p>《<a href="http://blogs.msdn.com/vstsqualitytools/archive/2009/06/12/automated-user-interface-testing-with-coded-ui-test.aspx" target="_blank">Automated User Interface Testing with Coded UI Test</a>》VSTT官方博客出品，Coded UI Test入门</p>
<p>《<a href="http://blogs.msdn.com/billbar/archive/2009/06/09/vsts-2010-load-test-feature-saving-test-logs.aspx" target="_blank">VSTS 2010 Load Test Feature: Saving Test Logs</a>》如何在VS的负载测试中记录日志，帮助定位问题</p>
<p>《<a href="http://blogs.msdn.com/slumley/archive/2009/06/09/vsts-2010-feature-load-test-virtual-user-activity-visualization.aspx" target="_blank">VSTS 2010 Feature: Load test virtual user activity visualization</a>》如果在用VSTS进行性能测试进行的过程中，CPU突然有一个不寻常的峰值出现，在以前是比较难找到原因的，此文给我们介绍了VSTS 2010的最新功能virtual user activity visualization 是如何帮助测试工程师找到问题的根源</p>
<p>《<a href="http://blogs.msdn.com/slumley/pages/vsts-2010-feature-web-test-recorder-plugins.aspx" target="_blank">VSTS 2010 Feature: Web Test Recorder Plugins</a>》如何在VSTS 2010中利用Web Test Recorder Plugins来做自定义的关联</p>
<p>《<a href="http://geekswithblogs.net/jakob/archive/2009/06/04/vsts-2010-enabling-test-impact-analysis.aspx" target="_blank">VSTS 2010: Enabling Test Impact Analysis</a>》文章介绍了如何使用Test Impact Analysis</p>
<p>《<a href="http://blogs.msdn.com/vstsqualitytools/archive/2009/05/29/the-evolution-of-the-ui-design-of-test-and-lab-manager.aspx" target="_blank">The Evolution of the UI Design of Test and Lab Manager</a>》一篇概要介绍 Lab Manager的文章</p>
<p>《<a href="http://msdn.microsoft.com/zh-cn/library/dd380763(en-us,VS.100).aspx" target="_blank">Quick Start Guide for Manual Testing</a>》MSDN上一篇讲述手动测试工程师如何用Lab Manager开展工作的文章</p>
<p>《<a href="http://blogs.msdn.com/jasonz/archive/2009/05/26/vs2010-tutorial-testing-tutorial-step-2.aspx" target="_blank">VS2010 Tutorial: Testing Tutorial (Step 2)</a>》文章极其详细地讲述了如何用VSTS 2010来提交一个BUG，并且展示一系列的新功能，来说明VSTS 2010如何帮助消除开发和测试之间的隔阂，减少那些不可重现的BUG。</p>
<p>《<a href="http://www.clemensreijnen.nl/post/Testing-in-the-Application-Lifecycle-with-Visual-Studio-2010-Test-Edition.aspx" target="_blank">Testing in the Application Lifecycle with Visual Studio 2010 Test Edition</a>》此文详细介绍了在VSTS2010中，测试工程师在整个应用开发生命周期中如何利用VSTS来帮助开展工作</p>
<p>《<a href="http://blogs.msdn.com/ratnaditya/archive/2009/06/01/running-automated-tests-in-manual-test-and-lab-manager-vsts-2010.aspx" target="_blank">Running automated tests in Manual Test and Lab Manager</a>》此文介绍了在Lab Manger中如何运行各种测试的方法</p>
<p>《<a href="http://blogs.msdn.com/slumley/pages/vs-2010-feature-web-test-playback-enhancements.aspx" target="_blank">VSTS 2010 Feature: Web Test Playback Enhancements</a>》文章介绍Web Test在UI方面的更新</p>
<p>《<a href="http://blogs.msdn.com/edglas/archive/2009/05/24/read-this-before-running-a-load-test-with-dev10-beta-1.aspx" target="_blank">Read this Before Running a Load Test with Dev10 Beta 1</a>》如果你的VSTS2010和2008是安装在同一台机器上，并且你又实用了VS的负载测试，那么这篇文章会告诉你如果对数据库进行设置，使得两个版本的负载测试数据能够共存互不影响</p>
<p>《<a href="http://blogs.infosupport.com/blogs/marcelv/archive/2009/05/22/how-to-enable-code-coverage-in-visual-studio-2010-unit-tests.aspx" target="_blank">How to enable code coverage in Visual Studio 2010 Unit tests</a>》，由于VSTS2010对于测试运行的一些改变，所以要打开代码覆盖率的操作与VS2008有所不同，这篇文章给我们讲述了操作细节</p>
<p>《<a href="http://blogs.msdn.com/mathew_aniyan/archive/2009/05/26/coded-ui-test-from-microsoft-test-lab-manager.aspx" target="_blank">Coded UI Test from Microsoft Test &amp; Lab Manager</a>》如何在VSTS的最新的Lab Manager中运行CodedUI Test</p>
<p>《<a href="http://blogs.msdn.com/mathew_aniyan/archive/2009/05/26/coded-ui-test-in-a-team-build.aspx" target="_blank">Coded UI Test in a Team Build</a>》这篇文章讲述了如何把一个CodedUI Test加到TEAM BUILD里面</p>
<p>《<a href="http://blogs.msdn.com/amit_chatterjee/archive/2009/05/24/the-lab-management-product-an-overview.aspx" target="_blank">The Lab Management Product – An Overview</a>》 Lab Management产品介绍。</p>
<p>《<a href="http://blogs.msdn.com/amit_chatterjee/archive/2009/05/14/official-names-for-the-2010-test-products-now-announced.aspx" target="_blank">Official Names for the 2010 Test Products now announced!</a> 》介绍了VSTS2010中，3个不同版本所包含的不同功能。</p>
<p>《<a href="http://blogs.msdn.com/slumley/pages/dev-10-feature-creating-excel-reports-for-load-test-data.aspx" target="_blank">VSTS 2010 Feature: Creating excel reports for Load Test Data</a>》，一篇介绍在VSTS2010中，如何创建一个Excel格式的性能报告的文章。</p>
<p>《<a href="http://blogs.msdn.com/edglas/archive/2009/05/24/read-this-before-running-a-load-test-with-dev10-beta-1.aspx" target="_blank">Rename load test database name before running a long test with VSTS2010 beta1</a>》，这篇文章告诉我们，如果VSTS2008和2010都安装在同一台机子上，那么在2010中运行负载测试的时候会更新数据库的schema，为了让VSTS2008的负载测试数据库和VS2010的共存，需要修改数据库的名字。</p>
<p>《<a href="http://blog.dynatrace.com/2009/05/20/how-to-extend-visual-studio-2010-web-and-load-testing-with-transactional-tracing/" target="_blank">How to extend Visual Studio 2010 Web- and Load-Testing with Transactional Tracing</a>》这篇文章讲述了如何给WEB测试做扩展。图文并茂！</p>
<p>《<a href="http://blogs.msdn.com/edglas/archive/2009/05/19/elevating-the-role-of-the-tester-with-visual-studio-2010.aspx" target="_blank">Elevating the Role of the Tester with Visual Studio 2010</a>》这篇文章详细讲述了各种各样测试工程师可以利用VSTS2010做什么样的东西，作者是VSTS测试人员版本的经理</p>
<p>《<a href="http://blogs.msdn.com/edglas/archive/2009/05/18/dev10-beta-1-available.aspx" target="_blank">Dev10 Beta 1 Available!</a>》这篇文章详细列出了VSTS2010 BETA1中，有关测试部分的更新。</p>
<p><strong>视频：</strong></p>
<p><a href="http://videos.visitmix.com/MIX09/T83M" target="_blank">Automated User Interface (UI) Testing with Microsoft Visual Studio Team System 2010</a>。一个微软的人介绍CodedUI Test，还有Test Impact，17分钟。</p>
<p><a href="http://channel9.msdn.com/shows/10-4/10-4-Episode-23-An-Introduction-to-Manual-Testing/" target="_blank">An Introduction to Manual Testing</a>。</p>
<p><strong>博客：</strong></p>
<p><a href="http://blogs.msdn.com/amit_chatterjee/default.aspx" target="_blank">Amit Chatterjee&#8217;s Blog</a>，VSTS的一个产品经理，这里经常会有关于VSTS测试部分的更新介绍</p>
<p><a href="http://blogs.msdn.com/edglas/default.aspx" target="_blank">Ed Glas&#8217;s blog on VSTS load testing</a>，也是VSTS的一个经理，他的博客主要关注Load Test和Web Test</p>
<p><a href="http://blogs.msdn.com/mathew_aniyan/" target="_blank">Mathew Aniyan&#8217;s Blog</a>，来路不明，Coded UI Test之霸！</p>
<p><a href="http://blogs.gotdotnet.com/lab_management/default.aspx" target="_blank">VSTS Lab Management team blog</a>，Lab Management官方博客</p>
<p><a href="http://blogs.msdn.com/vstsqualitytools/default.aspx" target="_blank">VS Team System Test</a>，VSTT官方博客</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://magustest.com/blog/softwaretesting/vsts2010-test-edition-article-collection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>用VSTS Profiler发现性能问题并且进行优化实例</title>
		<link>http://magustest.com/blog/net/using-vsts-profiler-find-bottleneck-and-optimize/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=using-vsts-profiler-find-bottleneck-and-optimize</link>
		<comments>http://magustest.com/blog/net/using-vsts-profiler-find-bottleneck-and-optimize/#comments</comments>
		<pubDate>Thu, 23 Apr 2009 04:11:50 +0000</pubDate>
		<dc:creator>magus</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[性能测试]]></category>
		<category><![CDATA[Profiler]]></category>
		<category><![CDATA[VSTS]]></category>

		<guid isPermaLink="false">http://magustest.com/blog/?p=439</guid>
		<description><![CDATA[上一篇文章介绍了如何使用VSTS的Profiler，今天想分享一下对于一个ASP.NET应用程序，用Profiler找到性能问题并且对之进行优化。 由于ASP.NET程序运行在一个硕大的框架上，所以一般用Sample模式收集到的数据，对发现性能问题帮助不大，以下是一个用Sample模式收集的结果： 从这个报告中我们可以看到，前5个工作量最大的函数和执行单独工作最多的函数都是系统函数。 下面看一下有针对性地用检测模式收集的数据： 本文就采用“检测”模式收集性能数据来进行分析和处理。 首先，把本次测试的目标DLL用VSInstr工具进行处理，使得Profiler能够收集相关的性能数据，这一个步骤非常关键，通常来说不需要设置额外的参数，就是默认的方式就可以了，例如：VSInstr “D:\Websites\xxxx\bin\xxxx.dll”，在处理的过程中可能会提示一些错误，具体错误的信息可以在这里查找。把相应的DLL处理完毕以后，就在命令行输入以下指令（命令行的指令用斜体加下划线表示；说明文字加黑） 停止IIS iisreset /stop 设置分析.NET应用程序所需要的环境变量，在运行完这个命令以后需要重启。由于使用检测方式进行数据采集，所以这里我用globaltraceon参数。 VSPerfClrEnv /globaltraceon 启动性能数据收集。/start:trace，告诉收集器要收集检测数据；/user:”NETWORK SERVICE” ，由于是要对IIS进行的数据进行采集，所以需要制定用户NETWORK SERVICE；/CS，启用跨进程分析，看了一些文章说是分析ASP.NET程序一般都把这个选项打开，原因不详；/output:”d:\magus\0422.vsp”，指定输出文件的路径和名称；/wincounter:”\Processor(_Total)\% Processor Time”，收集处理器的参数，这里需要注意的是，wincouter后面的性能计数器名字一定要是全名，有一个方法可以查询系统的性能计数器的全称，就是用VSTS的Server Explorer，然后找到相应的服务器(一般是本机)，下面有一个“Performance Counters”；如果要收集多个性能计数器的数据，只需要多加几个 /wincounter 参数即可，例如我在收集处理器时间的同时，还想知道Context Switcher每秒的数据。 VSPerfCmd /start:trace /user:”NETWORK SERVICE” /CS /output:”d:\magus\0422.vsp” /wincounter:”\Processor(_Total)\% Processor Time” /wincounter:”\System\Context Switches/sec” 在IIS起来之前先停止性能数据的收集 VSPerfCmd /globaloff 启动IIS iisreset /start 对程序进行预热，这一步也是很关键，因为IIS启动以后，程序需要预热才能达到稳定的状态，因为程序首次被访问的时候有些代码会被编译，所以为了降低对性能测试的影响，应该现对被测的程序进行预热。在预热完毕以后重新启动性能数据的收集。 VSPerfCmd /globalon &#8211; 运行性能测试场景 &#8211; 测试运行完毕以后，停止性能数据的收集 VSPerfCmd /globaloff 停掉IIS iisreset /stop 关闭性能数据收集器，这一步完成以后就能生成包含数据的文件了 VSPerfCmd <a href='http://magustest.com/blog/net/using-vsts-profiler-find-bottleneck-and-optimize/'>[...]</a>
No related posts.]]></description>
			<content:encoded><![CDATA[<p>上一篇文章介绍了<a href="http://magustest.com/blog/net/intruduction-to-vsts-profile/" target="_blank">如何使用VSTS的Profiler</a>，今天想分享一下对于一个ASP.NET应用程序，用Profiler找到性能问题并且对之进行优化。</p>
<p>由于ASP.NET程序运行在一个硕大的框架上，所以一般用Sample模式收集到的数据，对发现性能问题帮助不大，以下是一个用Sample模式收集的结果：</p>
<p><img class="alignnone size-full wp-image-442" title="iis-sample" src="http://magustest.com/blog/wp-content/uploads/2009/04/iis-sample1.png" alt="iis-sample" width="549" height="236" /></p>
<p>从这个报告中我们可以看到，前5个工作量最大的函数和执行单独工作最多的函数都是系统函数。</p>
<p>下面看一下有针对性地用检测模式收集的数据：</p>
<p><img class="alignnone size-full wp-image-444" title="instr-function-with-indi-work1" src="http://magustest.com/blog/wp-content/uploads/2009/04/instr-function-with-indi-work11.png" alt="instr-function-with-indi-work1" width="532" height="139" /></p>
<p>本文就采用“检测”模式收集性能数据来进行分析和处理。</p>
<p>首先，把本次测试的目标DLL用VSInstr工具进行处理，使得Profiler能够收集相关的性能数据，这一个步骤非常关键，通常来说不需要设置额外的参数，就是默认的方式就可以了，例如：VSInstr “D:\Websites\xxxx\bin\xxxx.dll”，在处理的过程中可能会提示一些错误，具体错误的信息可以在<a href="http://msdn.microsoft.com/en-us/library/ms242734.aspx" target="_blank">这里</a>查找。把相应的DLL处理完毕以后，就在命令行输入以下指令（命令行的指令用斜体加下划线表示；说明文字加黑）<br />
<span id="more-439"></span><br />
<strong>停止IIS</strong></p>
<p><span style="text-decoration: underline;"><em>iisreset /stop</em></span></p>
<p><strong>设置分析.NET应用程序所需要的环境变量，在运行完这个命令以后需要重启。由于使用检测方式进行数据采集，所以这里我用globaltraceon参数。</strong></p>
<p><span style="text-decoration: underline;"><em>VSPerfClrEnv /globaltraceon</em></span></p>
<p><strong>启动性能数据收集。<span style="text-decoration: underline;">/start:trace</span>，告诉收集器要收集检测数据；/user:”NETWORK SERVICE” ，由于是要对IIS进行的数据进行采集，所以需要制定用户NETWORK SERVICE；<span style="text-decoration: underline;">/CS</span>，启用跨进程分析，看了一些文章说是分析ASP.NET程序一般都把这个选项打开，原因不详；<span style="text-decoration: underline;">/output:”d:\magus\0422.vsp”</span>，指定输出文件的路径和名称；<span style="text-decoration: underline;">/wincounter:”\Processor(_Total)\% Processor Time”</span>，收集处理器的参数，这里需要注意的是，wincouter后面的性能计数器名字一定要是全名，有一个方法可以查询系统的性能计数器的全称，就是用VSTS的Server Explorer，然后找到相应的服务器(一般是本机)，下面有一个“Performance Counters”；如果要收集多个性能计数器的数据，只需要多加几个 /wincounter 参数即可，例如我在收集处理器时间的同时，还想知道Context Switcher每秒的数据。</strong></p>
<p><span style="text-decoration: underline;"><em>VSPerfCmd /start:trace /user:”NETWORK SERVICE” /CS /output:”d:\magus\0422.vsp” /wincounter:”\Processor(_Total)\% Processor Time” /wincounter:”\System\Context Switches/sec”</em></span></p>
<p><strong>在IIS起来之前先停止性能数据的收集</strong></p>
<p><span style="text-decoration: underline;"><em>VSPerfCmd /globaloff</em></span></p>
<p><strong>启动IIS</strong></p>
<p><em><span style="text-decoration: underline;">iisreset /start</span></em></p>
<p><strong>对程序进行预热，这一步也是很关键，因为IIS启动以后，程序需要预热才能达到稳定的状态，因为程序首次被访问的时候有些代码会被编译，所以为了降低对性能测试的影响，应该现对被测的程序进行预热。在预热完毕以后重新启动性能数据的收集。</strong></p>
<p><em><span style="text-decoration: underline;">VSPerfCmd /globalon</span></em></p>
<p><strong>&#8211; 运行性能测试场景 &#8211;<br />
</strong></p>
<p><strong>测试运行完毕以后，停止性能数据的收集</strong></p>
<p><em><span style="text-decoration: underline;">VSPerfCmd /globaloff</span></em></p>
<p><strong>停掉IIS</strong></p>
<p><em><span style="text-decoration: underline;">iisreset /stop</span></em></p>
<p><strong>关闭性能数据收集器，这一步完成以后就能生成包含数据的文件了</strong></p>
<p><em><span style="text-decoration: underline;">VSPerfCmd /shutdown</span></em></p>
<p>首先来看看收集到的报告</p>
<p><img class="alignnone size-full wp-image-447" title="time-before-opt1" src="http://magustest.com/blog/wp-content/uploads/2009/04/time-before-opt11.png" alt="time-before-opt1" width="547" height="55" /></p>
<p>在这个方法里面有一段不知名方法（其实是因为没有相应的Symbol，⊙﹏⊙b汗）占用了大量的计算时间，然后就找到相应的代码，原来该不知名方法是一个动态生成的代码，该段代码大概就是会创建一个新的Client对象，然后向另外一台服务器发起一个请求。其实不用每次调用该方法都创建一个新的Client对象。然后我尝试着把这个Client改为静态变量，经过优化以后的报告对比如下：</p>
<p><img class="alignnone size-full wp-image-448" title="time-after-opt" src="http://magustest.com/blog/wp-content/uploads/2009/04/time-after-opt1.png" alt="time-after-opt" width="523" height="251" /></p>
<p>效果还是挺明显的，但是当我重新测试一下性能的时候，被打击了一下，改动前后的性能对比相差很小，小的都可以认为是误差：P，因为在一个颇为庞大的项目中，这点小小的改动的确不可能影响大局。不过这次试验让我学会了用Profiler来找到ASP.NET运行中执行较慢的语句，并且看看这些语句有什么问题（可能是一个调用存储过程的方法很慢，而真正的原因是数据库有问题），定位问题所在，然后解决问题，最后回测一下对比改动前后的结果。看是否达到预期的优化效果。</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://magustest.com/blog/net/using-vsts-profiler-find-bottleneck-and-optimize/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VSTS性能分析工具Profiler的介绍</title>
		<link>http://magustest.com/blog/net/intruduction-to-vsts-profile/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=intruduction-to-vsts-profile</link>
		<comments>http://magustest.com/blog/net/intruduction-to-vsts-profile/#comments</comments>
		<pubDate>Wed, 22 Apr 2009 08:41:23 +0000</pubDate>
		<dc:creator>magus</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[性能测试]]></category>
		<category><![CDATA[Profiler]]></category>
		<category><![CDATA[VSTS]]></category>

		<guid isPermaLink="false">http://magustest.com/blog/?p=426</guid>
		<description><![CDATA[在MSDN文档中，对于VSTS中的Development Edition的介绍主要分两大块，第一是“编写高质量的代码”，第二就是“使用分析工具对应用程序性能进行分析”。在VSTS里面有一个工具，叫Profiler，这个工具可以帮助研发人员在程序运行的过程中收集相关的数据，并且对之进行分析，从而达到帮助实现性能调优的目的。本文讲述如何在使用命令行工具来对ASP.NET程序进行性能测试相关数据的收集。 在VSTS的Profiler中，有两种(VSTS2010好像有5种了)Profiling的方法，第一种是采样(Sampling)，第二种是检测(Instrumentation)。对于采样模式，它的工作原理是Profiler定期中断CPU并且收集函数的调用堆栈信息。在网上找到一个图，对于采样工作方式的描述非常清晰： 对于检测模式，他的工作原理是用VSInstr程序在原始的代码中插入一些用于计算时间的代码，例如A函数调用B函数，那么在调用B函数的前后都会被插入用于计算时间的代码，具体可以看下图： 下面我自己写了一个小的Sample类，然后把编译好的代码用Reflector来查看，很容易地就能看出区别。第一个图是没有经过VSInstr处理的原始代码： 下图就是经过VSInstr处理后，反编译后的代码： 可以看到VSInstr程序修改了原来的DLL。在检测模式下，只有经过修改后的DLL才能收集到数据。 在VSTS中，一般可以通过Analyze菜单下的Launch Performance Wizard来新建一个性能会话，然后进行性能数据的采集。 对于ASP.NET程序，可以通过以下步骤来进行“采样” iisreset /stop VSPerfClrEnv /globalsampleon VSPerfCmd /start:sample /user:”NETWORK SERVICE” /output:”d:\somewhere\xxxx.vsp” VSPerfCmd /globaloff iisreset /start VSPerfCmd /attach:xxxx VSPerfCmd /globalon &#8211;run the test scenario&#8211; VSPerfCmd /globaloff VSPerfCmd /detach iisreset /stop VSPerfCmd /shutdown 第一步是停掉IIS 然后通过VSPerfClrEnv对环境变量进行设置，具体可以查文档，做完这一步以后通常需要重启一下电脑 第三步就是通过VSPerfCmd启动性能数据收集 接下来的VSPerfCmd /globaloff就是暂停性能数据的收集 然后重启IIS，并且访问一下这个服务器上的页面，使得W3WP进程启动 查看W3WP.EXE的进程ID，然后通过VSPerfCmd /attach:xxxx把Profiler attach到IIS中 通过VSPerfCmd /globalon重新让Profiler进行性能数据的采集 然后就可以运行性能测试的场景 运行测试完毕以后就用VSPerfCmd /globaloff停止性能数据的采集 接着用VSPerfCmd <a href='http://magustest.com/blog/net/intruduction-to-vsts-profile/'>[...]</a>
No related posts.]]></description>
			<content:encoded><![CDATA[<p>在<a href="http://msdn.microsoft.com/zh-cn/library/47f7hz7y.aspx" target="_blank">MSDN文档</a>中，对于VSTS中的Development Edition的介绍主要分两大块，第一是“编写高质量的代码”，第二就是“使用分析工具对应用程序性能进行分析”。在VSTS里面有一个工具，叫Profiler，这个工具可以帮助研发人员在程序运行的过程中收集相关的数据，并且对之进行分析，从而达到帮助实现性能调优的目的。本文讲述如何在使用命令行工具来对ASP.NET程序进行性能测试相关数据的收集。</p>
<p>在VSTS的Profiler中，有两种(VSTS2010好像有5种了)Profiling的方法，第一种是采样(Sampling)，第二种是检测(Instrumentation)。对于采样模式，它的工作原理是Profiler定期中断CPU并且收集函数的调用堆栈信息。在网上找到一个图，对于采样工作方式的描述非常清晰：</p>
<p><img class="alignnone size-full wp-image-429" title="how-sampling-works" src="http://magustest.com/blog/wp-content/uploads/2009/04/how-sampling-works1.jpg" alt="how-sampling-works" width="500" height="330" /></p>
<p>对于检测模式，他的工作原理是用VSInstr程序在原始的代码中插入一些用于计算时间的代码，例如A函数调用B函数，那么在调用B函数的前后都会被插入用于计算时间的代码，具体可以看下图：<br />
<span id="more-426"></span><br />
<img class="alignnone size-full wp-image-430" title="how-instr-works" src="http://magustest.com/blog/wp-content/uploads/2009/04/how-instr-works1.jpg" alt="how-instr-works" width="600" height="300" /></p>
<p>下面我自己写了一个小的Sample类，然后把编译好的代码用Reflector来查看，很容易地就能看出区别。第一个图是没有经过VSInstr处理的原始代码：</p>
<p><img class="alignnone size-full wp-image-431" title="before-instr" src="http://magustest.com/blog/wp-content/uploads/2009/04/before-instr1.png" alt="before-instr" width="351" height="274" /></p>
<p>下图就是经过VSInstr处理后，反编译后的代码：</p>
<p><img class="alignnone size-full wp-image-432" title="after-instr" src="http://magustest.com/blog/wp-content/uploads/2009/04/after-instr1.png" alt="after-instr" width="600" height="356" /></p>
<p>可以看到VSInstr程序修改了原来的DLL。在检测模式下，只有经过修改后的DLL才能收集到数据。</p>
<p>在VSTS中，一般可以通过Analyze菜单下的Launch Performance Wizard来新建一个性能会话，然后进行性能数据的采集。</p>
<p><span style="font-size: medium;"><strong>对于ASP.NET程序，可以通过以下步骤来进行“采样”</strong></span></p>
<blockquote><p>iisreset /stop<br />
VSPerfClrEnv /globalsampleon<br />
VSPerfCmd /start:sample /user:”NETWORK SERVICE” /output:”d:\somewhere\xxxx.vsp”<br />
VSPerfCmd /globaloff<br />
iisreset /start<br />
VSPerfCmd /attach:xxxx<br />
VSPerfCmd /globalon</p>
<p>&#8211;run the test scenario&#8211;</p>
<p>VSPerfCmd /globaloff<br />
VSPerfCmd /detach<br />
iisreset /stop<br />
VSPerfCmd /shutdown</p></blockquote>
<ol>
<li>第一步是停掉IIS</li>
<li>然后通过VSPerfClrEnv对环境变量进行设置，具体可以查文档，做完这一步以后通常需要重启一下电脑</li>
<li>第三步就是通过VSPerfCmd启动性能数据收集</li>
<li>接下来的VSPerfCmd /globaloff就是暂停性能数据的收集</li>
<li>然后重启IIS，并且访问一下这个服务器上的页面，使得W3WP进程启动</li>
<li>查看W3WP.EXE的进程ID，然后通过VSPerfCmd /attach:xxxx把Profiler attach到IIS中</li>
<li>通过VSPerfCmd /globalon重新让Profiler进行性能数据的采集</li>
<li>然后就可以运行性能测试的场景</li>
<li>运行测试完毕以后就用VSPerfCmd /globaloff停止性能数据的采集</li>
<li>接着用VSPerfCmd /detach让Profiler不要附着在IIS上</li>
<li>停掉IIS &#8212; iisreset /stop</li>
<li>执行VSPerfCmd /shutdown，这一步执行完毕以后，在d:\somewhere\下就有一个xxxx.vsp的性能报告。</li>
</ol>
<p><span style="font-size: medium;"><strong>对于ASP.NET程序，可以通过以下步骤来进行“检测”</strong></span></p>
<p>检测和采样其实是大同小异的，但是有一个关键的步骤就是在进行检测之前，一定要记得用VSInstr命令对需要进行检测的DLL或者EXE文件进行处理，建议一次不要检测太多文件，检测时间不要太长，因为检测所产生的数量是非常大的，产生的文件大小都是按G级别计算了。</p>
<blockquote><p>iisreset /stop<br />
VSPerfClrEnv /globaltraceon<br />
VSPerfCmd /start:trace /user:”NETWORK SERVICE” /CS /output:”d:\xxx\0422.vsp”<br />
VSPerfCmd /globaloff<br />
iisreset /start<br />
&#8211; 预热 &#8211;<br />
VSPerfCmd /globalon</p>
<p>&#8211;run code&#8211;</p>
<p>VSPerfCmd /globaloff<br />
iisreset /stop<br />
VSPerfCmd /shutdown</p></blockquote>
<p>重复一次，在做以上的步骤之前必须要用VSInstr对目标二进制文件进行处理。这里详细步骤就不做解释了，命令的主要区别就是在做检测的时候，就免去了Attach到IIS这个步骤了。</p>
<p>采样和检测，前者是宏观的性能数据采集，后者是微观的性能数据采集。对于CPU负载较高的程序，用采样会得到比较好的效果；但是如果程序运行过程中并没有消耗很多的CPU资源，那么用采样可能就不能收集到太多有用的信息。所以在不同的场景下需要应用不同的性能数据收集方法。</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://magustest.com/blog/net/intruduction-to-vsts-profile/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>图解微软性能测试工具VSTS2008 Load Test Agent安装</title>
		<link>http://magustest.com/blog/loadtest/vsts-load-controller-and-load-agent-installation/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=vsts-load-controller-and-load-agent-installation</link>
		<comments>http://magustest.com/blog/loadtest/vsts-load-controller-and-load-agent-installation/#comments</comments>
		<pubDate>Fri, 26 Dec 2008 16:18:35 +0000</pubDate>
		<dc:creator>magus</dc:creator>
				<category><![CDATA[性能测试]]></category>
		<category><![CDATA[VSTS]]></category>

		<guid isPermaLink="false">http://magustest.com/blog/?p=251</guid>
		<description><![CDATA[最近在用VSTS做性能测试的时候发现本地发起请求只能占用1个CPU，其余的CPU都是空闲的，上网查了一下，这个是因为用VSTS做性能测试的时候，发起压力的进程是VSTESTHost.exe，如果想让多核CPU的每一个CPU都产生压力，需要安装使用Visual Studio Team System Test Load Agent。这个工具是要钱的，即使你订阅了MSDN的什么版本，在下载中心里面下载到的都是90天试用版，可能也是因为这个原因，网上很少资料介绍如何安装和使用这个Load Agent。经过1个下午的摸索，成功配置成功，以下是在Windows Server 2003下安装Visual Studio Team System Test Load Agent的过程，VSTS，Controller和Agent都安装在同一台电脑上。 首先安装VSTS2008。 然后去微软的网站下载Visual Studio Team System Test Load Agent试用版。是一个ISO文件，用虚拟光驱挂上，然后开始安装。 如果要把Controller和Agent都安装在同一台电脑上，需要先安装Controller。安装的时候需要输入Windows的帐户和密码。整个过程不会太长，期间会默认安装SQL 2005 EXPRESS版，因为controller需要把测试的结果记录在数据库中。 安装好了controller以后，就可以安装Load Agent了，如图，也是需要输入windows的帐户和密码： 安装Agent会比安装controller多一个步骤，就是要指定controller，这里需要输入的controller的计算机名字，而不是什么LocalHost…… 如果都安装成功的话，可以在任务管理器里面找到以下3个进程：QTAgent.exe, QTAgentService.exe和QTController.exe 至此， Test Load Agent算是安装成功了，现在进入配置环节。 打开VSTS，配置Test Controller，如图： 进入配置菜单以后，需要配置： 控制器的名字：这里应该是计算机的名字，例如magusvm2003se Load Test Result Store：由于安装控制器的时候顺带安装了SQLEXPRESS，所以就用这个数据库 Agent：添加一个Agent，由于Agent也安装在一台机子上，所以就选择本机就好了。注意！状态需要为Ready才是正确的配置。 至此，Load Agent算是配置完毕了，但是还不能使用，因为当前的测试还没有配置为使用Load Agent来产生负载。 每一个测试项目，都有一个测试配置文件，现在我们就来修改这个测试配置文件吧，如图： 进入配置的窗口以后如图：需要把控制器选择为Remote，虽然其实是本地，但是从模式上来说就是Remote的。也因为只有选择Remote以后，才能选择controller，填入controller名字，这个名字是计算机的名字！！！ 到了这一步，就算是配置完成了，攻击吧，8个核心的压力机！ 最后希望大家能多讨论VSTS自带的性能测试工具，其实VSTS的LOAD TEST也是很强大的，还有推荐一篇关于如何安装Load Test Agent的文章 <a href='http://magustest.com/blog/loadtest/vsts-load-controller-and-load-agent-installation/'>[...]</a>
Related posts:<ol>
<li><a href='http://magustest.com/blog/softwaretesting/vsts2010-test-edition-article-collection/' rel='bookmark' title='VSTS 2010 Test Edition文章收集'>VSTS 2010 Test Edition文章收集</a></li>
<li><a href='http://magustest.com/blog/automationtesting/data-driven-codedui-test/' rel='bookmark' title='实现数据驱动的CodedUI Test'>实现数据驱动的CodedUI Test</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>最近在用VSTS做性能测试的时候发现本地发起请求只能占用1个CPU，其余的CPU都是空闲的，上网查了一下，这个是因为用VSTS做性能测试的时候，发起压力的进程是VSTESTHost.exe，如果想让多核CPU的每一个CPU都产生压力，需要安装使用Visual Studio Team System Test Load Agent。这个工具是要钱的，即使你订阅了MSDN的什么版本，在下载中心里面下载到的都是90天试用版，可能也是因为这个原因，网上很少资料介绍如何安装和使用这个Load Agent。经过1个下午的摸索，成功配置成功，以下是在Windows Server 2003下安装Visual Studio Team System Test Load Agent的过程，VSTS，Controller和Agent都安装在同一台电脑上。<br />
<span id="more-251"></span><br />
首先安装VSTS2008。</p>
<p>然后去微软的网站<a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=572E1E71-AE6B-4F92-960D-544CABE62162&amp;displaylang=en" target="_blank">下载Visual Studio Team System Test Load Agent试用版</a>。是一个ISO文件，用虚拟光驱挂上，然后开始安装。</p>
<p>如果要把Controller和Agent都安装在同一台电脑上，需要先安装Controller。安装的时候需要输入Windows的帐户和密码。整个过程不会太长，期间会默认安装SQL 2005 EXPRESS版，因为controller需要把测试的结果记录在数据库中。</p>
<p><a href="http://magustest.com/blog/wp-content/uploads/2008/12/install-controller1.png"><img class="alignnone size-full wp-image-253" title="install-controller" src="http://magustest.com/blog/wp-content/uploads/2008/12/install-controller1.png" alt="" width="500" height="443" /></a></p>
<p>安装好了controller以后，就可以安装Load Agent了，如图，也是需要输入windows的帐户和密码：</p>
<p><a href="http://magustest.com/blog/wp-content/uploads/2008/12/install-agent1.png"><img class="alignnone size-full wp-image-254" title="install-agent" src="http://magustest.com/blog/wp-content/uploads/2008/12/install-agent1.png" alt="" width="500" height="451" /></a></p>
<p>安装Agent会比安装controller多一个步骤，就是要指定controller，这里需要输入的controller的计算机名字，而不是什么LocalHost……</p>
<p><a href="http://magustest.com/blog/wp-content/uploads/2008/12/install-agent-fill-in-controller-name1.png"><img class="alignnone size-full wp-image-255" title="install-agent-fill-in-controller-name" src="http://magustest.com/blog/wp-content/uploads/2008/12/install-agent-fill-in-controller-name1.png" alt="" width="500" height="448" /></a></p>
<p>如果都安装成功的话，可以在任务管理器里面找到以下3个进程：QTAgent.exe, QTAgentService.exe和QTController.exe</p>
<p><a href="http://magustest.com/blog/wp-content/uploads/2008/12/process1.png"><img class="alignnone size-full wp-image-256" title="process" src="http://magustest.com/blog/wp-content/uploads/2008/12/process1.png" alt="" width="443" height="536" /></a></p>
<p>至此， Test Load Agent算是安装成功了，现在进入配置环节。</p>
<p>打开VSTS，配置Test Controller，如图：</p>
<p><a href="http://magustest.com/blog/wp-content/uploads/2008/12/admin-controller1.png"><img class="alignnone size-full wp-image-257" title="admin-controller" src="http://magustest.com/blog/wp-content/uploads/2008/12/admin-controller1.png" alt="" width="328" height="287" /></a></p>
<p>进入配置菜单以后，需要配置：</p>
<p>控制器的名字：这里应该是计算机的名字，例如magusvm2003se</p>
<p>Load Test Result Store：由于安装控制器的时候顺带安装了SQLEXPRESS，所以就用这个数据库</p>
<p>Agent：添加一个Agent，由于Agent也安装在一台机子上，所以就选择本机就好了。注意！状态需要为Ready才是正确的配置。</p>
<p><a href="http://magustest.com/blog/wp-content/uploads/2008/12/controller11.png"><img class="alignnone size-full wp-image-261" title="controller1" src="http://magustest.com/blog/wp-content/uploads/2008/12/controller11.png" alt="" width="484" height="379" /></a></p>
<p>至此，Load Agent算是配置完毕了，但是还不能使用，因为当前的测试还没有配置为使用Load Agent来产生负载。</p>
<p>每一个测试项目，都有一个测试配置文件，现在我们就来修改这个测试配置文件吧，如图：</p>
<p><a href="http://magustest.com/blog/wp-content/uploads/2008/12/edit-config1.png"><img class="alignnone size-full wp-image-259" title="edit-config" src="http://magustest.com/blog/wp-content/uploads/2008/12/edit-config1.png" alt="" width="500" height="280" /></a></p>
<p>进入配置的窗口以后如图：需要把控制器选择为Remote，虽然其实是本地，但是从模式上来说就是Remote的。也因为只有选择Remote以后，才能选择controller，填入controller名字，这个名字是计算机的名字！！！</p>
<p><a href="http://magustest.com/blog/wp-content/uploads/2008/12/choose-controller11.png"><img class="alignnone size-full wp-image-263" title="choose-controller1" src="http://magustest.com/blog/wp-content/uploads/2008/12/choose-controller11.png" alt="" width="500" height="355" /></a></p>
<p>到了这一步，就算是配置完成了，攻击吧，8个核心的压力机！</p>
<p><a href="http://magustest.com/blog/wp-content/uploads/2008/12/cpu1.png"><img class="alignnone size-full wp-image-262" title="cpu" src="http://magustest.com/blog/wp-content/uploads/2008/12/cpu1.png" alt="" width="448" height="442" /></a></p>
<p>最后希望大家能多讨论VSTS自带的性能测试工具，其实VSTS的LOAD TEST也是很强大的，还有推荐一篇关于如何安装Load Test Agent的文章</p>
<p><a href="http://blogs.msdn.com/edglas/pages/load-agent-and-load-controller-installation-and-configuration-guide.aspx" target="_blank">http://blogs.msdn.com/edglas/pages/load-agent-and-load-controller-installation-and-configuration-guide.aspx</a></p>
<p>Related posts:<ol>
<li><a href='http://magustest.com/blog/softwaretesting/vsts2010-test-edition-article-collection/' rel='bookmark' title='VSTS 2010 Test Edition文章收集'>VSTS 2010 Test Edition文章收集</a></li>
<li><a href='http://magustest.com/blog/automationtesting/data-driven-codedui-test/' rel='bookmark' title='实现数据驱动的CodedUI Test'>实现数据驱动的CodedUI Test</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://magustest.com/blog/loadtest/vsts-load-controller-and-load-agent-installation/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>LoadRunner模拟客户端发送JSON格式的请求</title>
		<link>http://magustest.com/blog/loadtest/json-format-request-using-loadrunner/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=json-format-request-using-loadrunner</link>
		<comments>http://magustest.com/blog/loadtest/json-format-request-using-loadrunner/#comments</comments>
		<pubDate>Thu, 25 Dec 2008 13:26:09 +0000</pubDate>
		<dc:creator>magus</dc:creator>
				<category><![CDATA[性能测试]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[LoadRunner]]></category>

		<guid isPermaLink="false">http://magustest.com/blog/?p=249</guid>
		<description><![CDATA[JSON格式的数据现在用的越来越多，在MySpace.CN，存在着2中web应用，一种是基于.NET平台的web应用，另一种是记录LAMP平台的web应用，要让这两种应用能够互相通信，需要制定一种通信格式，当时选择的就是JSON格式。今天接到一个任务，是要对一个批量获取用户数据的接口进行测试，这个接口介绍JSON格式的请求，返回JSON格式的结果。由于最近LAMP团队比较忙，而且我又不太懂怎么弄一个提交JSON的页面，所以只能找找LoadRunner有没有一些函数可以用。最终找到了web_custom_request这个函数。 1 2 3 4 5 6 7 8 9 10 11 web_custom_request&#40;&#34;request&#34;, //随便写个名字 &#34;Method=POST&#34;, //请求的方法 &#34;URL=http://10.60.0.13:8002/json/getUserAccounts&#34;, //请求地址 &#34;RecContentType=application/json&#34;, //指定相应头的Content-Type，这里是JSON &#34;EncType=application/json&#34;, //指定请求头的Content-Type，这里也是JSON &#34;Mode=HTML&#34;, RAW_BODY_START, //请求BODY开始的标识符 &#34;{\&#34;userIds\&#34;:[1300000001,1300002029,1300003163],\&#34;type\&#34;:0}&#34;, //BODY的内容 55, //上面一行BODY内容的长度 RAW_BODY_END, //请求BODY结束的标识符 LAST&#41;; 这样就是一个发起JSON格式请求，接受JSON格式数据的请求了。也是我写的第一个LR脚本，居然还不是录制的…… 在这里介绍一个计算BODY内容的长度的方法： 在Firefox上装好firebug这个插件 打开Firefox，然后打开控制台 在控制台里面输入BODY内容，然后用.length属性来获取该字符串的长度，如果对于上面这个例子，就是&#124;&#124; “{\”userIds\”:[1300000001,1300002029,1300003163],\”type\”:0}”.length &#124;&#124;，这样就能计算出结果“55” 很方便吧。而且还不会出错，不用数转义字符数目。 No related posts.
No related posts.]]></description>
			<content:encoded><![CDATA[<p>JSON格式的数据现在用的越来越多，在MySpace.CN，存在着2中web应用，一种是基于.NET平台的web应用，另一种是记录LAMP平台的web应用，要让这两种应用能够互相通信，需要制定一种通信格式，当时选择的就是<a href="http://www.json.org/json-zh.html" target="_blank">JSON格式</a>。今天接到一个任务，是要对一个批量获取用户数据的接口进行测试，这个接口介绍JSON格式的请求，返回JSON格式的结果。由于最近LAMP团队比较忙，而且我又不太懂怎么弄一个提交JSON的页面，所以只能找找LoadRunner有没有一些函数可以用。最终找到了web_custom_request这个函数。<br />
<span id="more-249"></span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="c" style="font-family:monospace;">web_custom_request<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;request&quot;</span><span style="color: #339933;">,</span>   <span style="color: #666666; font-style: italic;">//随便写个名字</span>
    <span style="color: #ff0000;">&quot;Method=POST&quot;</span><span style="color: #339933;">,</span>                         <span style="color: #666666; font-style: italic;">//请求的方法</span>
    <span style="color: #ff0000;">&quot;URL=http://10.60.0.13:8002/json/getUserAccounts&quot;</span><span style="color: #339933;">,</span>        <span style="color: #666666; font-style: italic;">//请求地址</span>
    <span style="color: #ff0000;">&quot;RecContentType=application/json&quot;</span><span style="color: #339933;">,</span>    <span style="color: #666666; font-style: italic;">//指定相应头的Content-Type，这里是JSON</span>
    <span style="color: #ff0000;">&quot;EncType=application/json&quot;</span><span style="color: #339933;">,</span>               <span style="color: #666666; font-style: italic;">//指定请求头的Content-Type，这里也是JSON</span>
    <span style="color: #ff0000;">&quot;Mode=HTML&quot;</span><span style="color: #339933;">,</span>
    RAW_BODY_START<span style="color: #339933;">,</span>                      <span style="color: #666666; font-style: italic;">//请求BODY开始的标识符</span>
    <span style="color: #ff0000;">&quot;{<span style="color: #000099; font-weight: bold;">\&quot;</span>userIds<span style="color: #000099; font-weight: bold;">\&quot;</span>:[1300000001,1300002029,1300003163],<span style="color: #000099; font-weight: bold;">\&quot;</span>type<span style="color: #000099; font-weight: bold;">\&quot;</span>:0}&quot;</span><span style="color: #339933;">,</span>  <span style="color: #666666; font-style: italic;">//BODY的内容</span>
    <span style="color: #0000dd;">55</span><span style="color: #339933;">,</span>                                    <span style="color: #666666; font-style: italic;">//上面一行BODY内容的长度</span>
    RAW_BODY_END<span style="color: #339933;">,</span>                  <span style="color: #666666; font-style: italic;">//请求BODY结束的标识符</span>
    LAST<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>这样就是一个发起JSON格式请求，接受JSON格式数据的请求了。也是我写的第一个LR脚本，居然还不是录制的……</p>
<p>在这里介绍一个计算BODY内容的长度的方法：</p>
<ol>
<li>在Firefox上装好<a href="https://addons.mozilla.org/firefox/addon/1843" target="_blank">firebug</a>这个插件</li>
<li>打开Firefox，然后打开控制台</li>
<li>在控制台里面输入BODY内容，然后用.length属性来获取该字符串的长度，如果对于上面这个例子，就是|| “{\”userIds\”:[1300000001,1300002029,1300003163],\”type\”:0}”.length ||，这样就能计算出结果“55”</li>
</ol>
<p>很方便吧。而且还不会出错，不用数转义字符数目。</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://magustest.com/blog/loadtest/json-format-request-using-loadrunner/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

