码迷,mamicode.com
首页 > 其他好文 > 详细

测试stopwatch频率

时间:2016-05-31 15:55:04      阅读:90      评论:0      收藏:0      [点我收藏+]

标签:

测试stopwatch频率

 1 using UnityEngine;
 2 using System.Collections;
 3 using System.Diagnostics;
 4 
 5 public class teststopwatch : MonoBehaviour {
 6 
 7 Stopwatch watch = new Stopwatch();
 8 
 9 // Use this for initialization
10 void Start() {
11 
12 }
13 
14 void OnGUI() {
15 watch.Start();
16 for (int i = 0; i < 10000; ++i) {
17 int j = i * i * 3 / 4;
18 }
19 watch.Stop();
20 float sec = watch.ElapsedMilliseconds / 1000.0f;
21 GUIStyle myGUIStyle = new GUIStyle();
22 myGUIStyle.fontSize = 50;
23 GUI.Label(new Rect(Screen.height / 3, 200, 200, 200), "Frequency:" + Stopwatch.Frequency.ToString(), myGUIStyle);
24 
25 }
26 
27 // Update is called once per frame
28 void Update () {
29 
30 }
31 }

 

最终结构都是 10000000

测试stopwatch频率

标签:

原文地址:http://www.cnblogs.com/YinaPan/p/stopwatchf.html

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