zoukankan      html  css  js  c++  java
  • C#之使用Stopwatch监视运行时间

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Diagnostics;

    namespace 使用Stopwatch01
    {
        
    class Program
        {
            
    static void Main(string[] args)
            {
                
    //System.Diagnostics.Stopwatch 可以用来测量程序段的运行时间
                
    //一般情况下在有多种途径(算法)来实现同一功能时,我们可能想对这两种方法进行一个比较,这个时候简单的使用下Stopwatch就可以有个大致的概念.
                int i = 0;
                
    int sum = 0;
                Stopwatch sw 
    = new Stopwatch();
                sw.Start();
                
    for (i = 0; i < 10000;i++ )
                {
                    sum
    +=i;               
                    Console.WriteLine(sum);
                }
                sw.Stop();
                Console.WriteLine(
    "使用时间" + sw.ElapsedMilliseconds);
                Console.ReadKey();
            }
        }
    }
  • 相关阅读:
    高斯消元
    逻辑运算符之优先级&&and、or
    康托展开
    关于bootstrap的双层遮罩问题
    写好页面在内网内访问
    swiper插件的一些坑
    第一篇博客
    poj 3415 Common Substrings
    poj 1509 Glass Beads
    poj 3260 The Fewest Coins
  • 原文地址:https://www.cnblogs.com/lizunicon/p/1394507.html
Copyright © 2011-2022 走看看