private void MultiObjectTimerTest() { Debugs.Log("MultiObjectBindTimerTest 시작"); List <GameObject> gameObjList = new List <GameObject>(); for (int i = 0; i < gameObjList.Count; i++) { Destroy(gameObjList[i]); } gameObjList.Clear(); for (int i = 0; i < 10; i++) { var newGo = new GameObject(string.Concat("MultiMainDispatchTimer", i)); gameObjList.Add(newGo); } Stopwatch sw = new Stopwatch(); Debugs.LogFormat("Start GO Timer Test - {0}", Time.realtimeSinceStartup); for (int i = 0; i < 1000; i++) { int index = i; int randSec = UnityEngine.Random.Range(0, 100); int randIdx = UnityEngine.Random.Range(0, 10); var go = gameObjList[randIdx]; Debugs.LogWarningFormat("I am {0}, reserve GO Timer - {1} Attatched To Object {2}", index, randSec.ToString(), randIdx); sw.Start(); GlobalDispatchTimer.Instance.PushTimerJob(() => { Debugs.LogErrorFormat("GO PPI BBIB - I am {0}, take {1} seconds", index, randSec); }, randSec, go); sw.Stop(); Destroy(go); } /* * GlobalDispatchTimer.Instance.PushTimerJob(() => * { * for (int i = 0; i < 10; i++) * Destroy(gameObjList[i]); * }, 10); */ Debugs.LogFormat("End GO Timer Test - {0}", Time.realtimeSinceStartup); Debugs.Log("Time : " + sw.ElapsedMilliseconds + "ms"); Debugs.Log("---------------------------------------------------------------------"); }
private void TimeReserveTest() { Debugs.Log("TimeReserveTest 시작"); List <GameObject> gameObjList = new List <GameObject>(); for (int i = 0; i < gameObjList.Count; i++) { Destroy(gameObjList[i]); } gameObjList.Clear(); for (int i = 0; i < 10; i++) { var newGo = new GameObject(string.Concat("MultiMainDispatchTimer", i)); gameObjList.Add(newGo); } Stopwatch sw = new Stopwatch(); Debugs.LogFormat("Start Reserve Timer Test - {0}", Time.realtimeSinceStartup); for (int i = 0; i < 1000; i++) { int index = i; int randSec = UnityEngine.Random.Range(0, 10); DateTime reserveTime = DateTime.Now.AddSeconds(randSec); Debugs.LogWarningFormat("I am {0}, reserve GO Timer - Reserve Time: {1}", index, randSec.ToString(), reserveTime); sw.Start(); GlobalDispatchTimer.Instance.PushTimerJob(() => { Debugs.LogErrorFormat("GO PPI BBIB - I am {0}, Difference: {1}ms", index, (DateTime.Now.Ticks - reserveTime.Ticks) / 10000L); }, reserveTime); sw.Stop(); } Debugs.Log("Time : " + sw.ElapsedMilliseconds + "ms"); //Debugs.Log("---------------------------------------------------------------------"); Debugs.Log("---------------------------------------------------------------------"); }
private void SingleObjectTimerTest() { Debugs.Log("SingleObjectTimerTest 시작"); Queue <GameObject> gameObjQueue = new Queue <GameObject>(); while (gameObjQueue.Count > 0) { var go = gameObjQueue.Dequeue(); Destroy(go); } for (int i = 0; i < 1000; i++) { var newGo = new GameObject(string.Concat("SingleMainDispatchTimer", i)); gameObjQueue.Enqueue(newGo); } Stopwatch sw = new Stopwatch(); Debugs.LogFormat("Start GO Timer Test - {0}", Time.realtimeSinceStartup); for (int i = 0; i < 1000; i++) { int index = i; int randSec = UnityEngine.Random.Range(0, 100); var go = gameObjQueue.Dequeue(); Debugs.LogWarningFormat("I am {0}, reserve GO Timer - {1}", index, randSec.ToString()); sw.Start(); GlobalDispatchTimer.Instance.PushTimerJob(() => { Debugs.LogErrorFormat("GO PPI BBIB - I am {0}, take {1} seconds", index, randSec); }, randSec, go); sw.Stop(); Destroy(go); } Debugs.LogFormat("End GO Timer Test - {0}", Time.realtimeSinceStartup); Debugs.Log("Time : " + sw.ElapsedMilliseconds + "ms"); Debugs.Log("---------------------------------------------------------------------"); }
private void SimpleTimerTest() { Stopwatch sw = new Stopwatch(); Debugs.LogFormat("Start Timer Test - {0}", Time.realtimeSinceStartup); for (int i = 0; i < 1000; i++) { int index = i; int randSec = UnityEngine.Random.Range(0, 100); Debugs.LogWarningFormat("I am {0}, reserve Timer - {1}", index, randSec.ToString()); sw.Start(); GlobalDispatchTimer.Instance.PushTimerJob(() => { Debugs.LogErrorFormat("PPI BBIB - I am {0}, take {1} seconds", index, randSec); }, randSec); sw.Stop(); } Debugs.LogFormat("End Timer Test - {0}", Time.realtimeSinceStartup); UnityEngine.Debug.Log("Time : " + sw.ElapsedMilliseconds + "ms"); }