• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • 執行軟件性能測試——起步

    發表于:2010-11-19來源:作者:點擊數: 標簽:性能測試軟件
    執行軟件 性能測試 ——起步 軟件測試 程序越來越大,為了讓程序更快地響應用戶的輸入,需要執行性能測試,最近在研究性能測試,就從這篇最基礎的文章開始起步吧。VS 2010自帶了一個功能強大的性能 測試工具 —Performance Wizard,在研究過程中,我決定用通

      執行軟件性能測試——起步  軟件測試

      程序越來越大,為了讓程序更快地響應用戶的輸入,需要執行性能測試,最近在研究性能測試,就從這篇最基礎的文章開始起步吧。VS 2010自帶了一個功能強大的性能測試工具—Performance Wizard,在研究過程中,我決定用通過分析最普通的排序操作的程序來開始我的學習過程。

      程序的功能很簡單,接受任何文本文件,排序,然后將結果輸出到一個新的文件中。第一個版本很簡單,使用最好寫的冒泡排序實現:

            #region 常見的排序方法 — 適合小文件的排序
            static void Main(string[] args)
            {
                if (args.Length != 2)
                {
                    Console.WriteLine("Usage: sort <file name> <output file name>");
                    return;
                }
     
                string[] sortedLines;
                using (StreamReader reader = new StreamReader(Path.GetFullPath(args[0])))
                {
                    var text = reader.ReadToEnd();
                    sortedLines = Sort(text);
                }
     
                using (StreamWriter writer = new StreamWriter(Path.GetFullPath(args[1])))
                {
                    foreach (var line in sortedLines)
                        writer.WriteLine(line);
                }
            }
     
            #region 使用冒泡排序來測試性能
            // V1: 使用冒泡排序來測試性能
            private static string[] Sort(string text)
            {
                var lines = text.Split(new string[] { "\r\n" }, StringSplitOptions.None);
     
                for (int i = 0; i < lines.Length; ++i)
                {
                    for (int j = i + 1; j < lines.Length; ++j)
                    {
                        if (string.CompareOrdinal(lines[i], lines[j]) < 0)
                        {
                            var temp = lines[i];
                            lines[i] = lines[j];
                            lines[j] = temp;
                        }
                    }
                }
     
                return lines;
            }
            #endregion

      使用一個大小為2.5 兆的文本文件作為輸入數據,并且用下面的步驟執行性能測試:

      1. 打開Visual Studio,并點擊菜單欄里的“分析(Analyze)”。

      2. 點擊“啟動性能測試向導(Launch Performance Wizard)”。

      3. 在“性能測試向導(Performance Wizard)”頁面上選擇“CPU Sampling (recommended)”。

      4. 在后續頁面上,使用頁面默認的選項做完設置。

      耐心等待程序執行完以后,Visual studio會提供一個報表,在摘要(Summary)里面—下圖,可以看到,程序使用了大約36秒才完成了所有的過程。

    原文轉自:http://www.kjueaiud.com

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>