测试stopwatch频率

测试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

posted @ 2016-05-31 14:22  YinaPan  阅读(348)  评论(0编辑  收藏  举报