示例#1
0
        public CustomTimerTaskObject()
        {
            secretKey = ++issuedKey;

            float reservedTime = Time.realtimeSinceStartup + UnityEngine.Random.Range(3, 10);

            ExecutedTicks = reservedTime;
            Debugs.LogFormat("CustomTimerTaskObject #{0} reserved at {0}, current: {1}", reservedTime, Time.realtimeSinceStartup);
        }
示例#2
0
    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("---------------------------------------------------------------------");
    }
示例#3
0
        public override void Execute()
        {
            int random = UnityEngine.Random.Range(0, 2);

            if (random % 2 == 0)
            {
                Dispose();
            }

            if (!isDeActivated)
            {
                Debugs.LogFormat("Executed CustomTimerTaskObject #{0}", secretKey);
            }
        }
示例#4
0
    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 LateUpdate()
        {
            if (isCalledDestroyed)
            {
                return;
            }

            if (!isRunning)
            {
                return;
            }

            CheckDestroyedGameObject();

            while (timedJobQueue.Count > 0)
            {
                var timedJob = timedJobQueue.Peek();

                if (CurrentTicks < timedJob.ExecutedTicks)
                {
                    break;
                }

                try
                {
                                        #if __USE_TIMER_LOG
                    Debugs.LogFormat("Execute Timer Job !!! - currentTicks {0}, job_excutedTicks {1}", CurrentTicks,
                                     timedJob.ExecutedTicks);
                                        #endif
                    timedJob.Execute();
                }
                catch (Exception ex)
                {
                    Debugs.LogError(string.Concat(ex.Message, ex.StackTrace));
                }
                finally
                {
                    // 어쩄든 큐에서 뺴자
                    timedJobQueue.Dequeue();
                }
            }
        }
示例#6
0
    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("---------------------------------------------------------------------");
    }
示例#7
0
    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");
    }
示例#8
0
 private void PushOnce()
 {
     Debugs.LogFormat("Reserve At {0}", DateTime.Now);
     GlobalDispatchTimer.Instance.PushTimerJob(() => { Debugs.LogErrorFormat("Calleed At {0}", DateTime.Now); }, 10);
 }
示例#9
0
 public override void Dispose()
 {
     Debugs.LogFormat("Disposed CustomTimerTaskObject #{0}", secretKey);
     base.Dispose();
 }