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

本文由博主(YinaPan)原创或者转载,如若转载请务必注明出处,谢谢合作!
原文地址:https://www.cnblogs.com/YinaPan/p/stopwatchf.html