zoukankan      html  css  js  c++  java
  • C#测试代码段运行速度

    CS代码:


               Stopwatch sw = new Stopwatch();

        sw.Start();

                int sum = 0;
                for (int i = 0; i < 100000; i++)
                {
                    sum += i;
                }
                sw.Stop();
                Label1.Text = "for循环:<br/>" + sw.Elapsed.ToString() + "<br/>";
                sw.Reset();

                sw.Start();
                sum = 0;
                int m = 100000;
                while (m != 0)
                {
                    sum += m;
                    m--;
                }
                sw.Stop();
                Label1.Text += "while循环:<br/>" + sw.Elapsed.ToString() + "<br/>"; 
  • 相关阅读:
    1924班网址
    20192414《网络空间安全导论》第一周学习总结
    H-Angry
    A-Plague Inc
    B-Rolling The Polygon
    F-Moving On
    A-Maximum Element In A Stack
    J-Word Search
    E-Pawns
    D-Lift Problems
  • 原文地址:https://www.cnblogs.com/mimengjiangnan/p/1864298.html
Copyright © 2011-2022 走看看