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();
            }
        }
    }
  • 相关阅读:
    关于自定义UICollectionViewLayout的一点个人理解<一>
    自定义进度条
    iOS 无限轮播图的两种实现
    图片的拉伸
    关于plist文件
    加载gif图过渡效果
    关于textView的字数限制
    php-fpm服务启动脚本
    转载:PHP支付宝接口RSA验证
    将博客搬至CSDN
  • 原文地址:https://www.cnblogs.com/lizunicon/p/1394507.html
Copyright © 2011-2022 走看看