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();
            }
        }
    }
  • 相关阅读:
    Python 简单总结
    Python 简单总结
    Python 简介
    Python基础题
    Python基础题
    tDQSS
    parameter–precharge, tRCD and tRAS
    parameter–key parameters
    parameter -- tWR
    命令集
  • 原文地址:https://www.cnblogs.com/lizunicon/p/1394507.html
Copyright © 2011-2022 走看看