码迷,mamicode.com
首页 > Windows程序 > 详细

C#检查一段代码的消耗时间

时间:2015-07-23 23:22:29      阅读:218      评论:0      收藏:0      [点我收藏+]

标签:

0.0 如果你想检查某一个函数循环的时间

System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
        stopwatch.Start();

        //这里是你想检测的时间

        stopwatch.Stop();
        System.TimeSpan timeSpan = stopwatch.Elapsed;
        double hours = timeSpan.TotalHours;
        double minutes = timeSpan.TotalMinutes;
        double seconds = timeSpan.TotalSeconds;
        double milliseconds = timeSpan.TotalMilliseconds;


        Debug.Log("总小时:" + hours);
        Debug.Log("总分钟:" + minutes);
        Debug.Log("总秒:" + seconds);
        Debug.Log("总毫秒:" + milliseconds);

C#检查一段代码的消耗时间

标签:

原文地址:http://www.cnblogs.com/plateFace/p/4671884.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!