• 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();
            }
        }
    }
  • 相关阅读:
    Retrofit源码分析
    Android异步消息机制
    崩溃bug日志总结3
    单例模式
    总结(第一段)
    mysql日期类型比较
    mysql记录(一)
    JSONObject/JSONArray的区别
    java 正则表达式(Pattern ,Matcher)的使用
    javaweb开发中的权限管理的方法
  • 原文地址:https://www.cnblogs.com/lizunicon/p/1394507.html
Copyright © 2020-2023  润新知