背景
一直做的是中小企業應用,很少關注性能和負載這里,進來准備看一本關於並發編程的圖書,為了量化的測試 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 }
負載測試
思考時間是指:發起一個測試請求的前置時間,如:發起登錄請求之前你要輸入用戶名和密碼。
用戶計數是指:同時有多少用戶在執行測試。
后面的自己慢慢摸索吧,我也不清楚了。
備注
通過使用測試工具,可以讓自己對並發和性能有一個相對理性的認識。