VisualStudio:WEB 性能測試和負載測試 入門


背景

一直做的是中小企業應用,很少關注性能和負載這里,進來准備看一本關於並發編程的圖書,為了量化的測試 WEB 環境的性能和負載,特意玩了一下 VS 提供的測試項目。

新的測試項目

新建項目

性能測試

自己可以嘗試添加測試邏輯,也可以編輯代碼(和 VS 提供的很多工具一樣)。

生成后的代碼:

 1 //------------------------------------------------------------------------------
 2 // <auto-generated>
 3 //     此代碼由工具生成。
 4 //     運行時版本:4.0.30319.18052
 5 //
 6 //     對此文件的更改可能會導致不正確的行為,並且如果
 7 //     重新生成代碼,這些更改將會丟失。
 8 // </auto-generated>
 9 //------------------------------------------------------------------------------
10 
11 namespace AsyncWebStudyTest
12 {
13     using System;
14     using System.Collections.Generic;
15     using System.Text;
16     using Microsoft.VisualStudio.TestTools.WebTesting;
17 
18 
19     public class 正常性能測試Coded : WebTest
20     {
21 
22         public 正常性能測試Coded()
23         {
24             this.PreAuthenticate = true;
25         }
26 
27         public override IEnumerator<WebTestRequest> GetRequestEnumerator()
28         {
29             WebTestRequest request1 = new WebTestRequest("http://localhost:2732/Default/");
30             yield return request1;
31             request1 = null;
32         }
33     }
34 }

負載測試

思考時間是指:發起一個測試請求的前置時間,如:發起登錄請求之前你要輸入用戶名和密碼。

用戶計數是指:同時有多少用戶在執行測試。

后面的自己慢慢摸索吧,我也不清楚了。

備注

通過使用測試工具,可以讓自己對並發和性能有一個相對理性的認識。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM