public static void START_FUNCTION_TIMER(string functionName)
 {
     TimedFunction timedFunc;
     if (!functionTimes.TryGetValue(functionName, out timedFunc))
         functionTimes.Add(functionName, timedFunc = new TimedFunction());
     timedFunc.SWatch.Start();
 }
Exemple #2
0
 public MI_Replace(TimedFunction oldTF, TimedFunction newTF, bool replaceAll, int amount)
 {
     OldTF       = oldTF;
     NewTF       = newTF;
     ReplaceAll  = replaceAll;
     this.amount = (amount >= 0) ? amount : -1;
 }
    public static void START_FUNCTION_TIMER(string functionName)
    {
        TimedFunction timedFunc;

        if (!functionTimes.TryGetValue(functionName, out timedFunc))
        {
            functionTimes.Add(functionName, timedFunc = new TimedFunction());
        }
        timedFunc.SWatch.Start();
    }
Exemple #4
0
    public void SetTimer(TimedFunction function, float delay)
    {
        TimedEvent e = new TimedEvent();

        e.function  = function;
        e.delay     = delay;
        e.addedTime = Time.time;

        timerList.Add(e);
    }
    public static void DISPLAY_FUNCTION_TIMER_AVERAGE(string functionName)
    {
        if (!functionTimes.ContainsKey(functionName))
        {
            UnityEngine.Debug.LogError("FunctionTimer::DisplayFunctionTimeAvg() -- Unknown function Name!");
            return;
        }

        TimedFunction timedFunc = functionTimes[functionName];

        double result = (timedFunc.TimeSum / timedFunc.Count);

        UnityEngine.Debug.Log(functionName + "() - Average Time = " + string.Format("{0:0.##}", result) + "ms Over " + timedFunc.Count + " iterations.");
    }
Exemple #6
0
 public MI_Replace(TimedFunction oldTF, TimedFunction newTF, bool replaceAll)
     : this(oldTF, newTF, replaceAll, -1)
 {
 }
Exemple #7
0
 public MI_Remove(TimedFunction tf, bool removeAll, int amount)
 {
     TF          = tf;
     RemoveAll   = removeAll;
     this.amount = (amount >= 0) ? amount : -1;
 }
Exemple #8
0
 public MI_Remove(TimedFunction tf, bool removeAll)
     : this(tf, removeAll, -1)
 {
 }
Exemple #9
0
 private long CallWithTimer(TimedFunction f)
 {
     this.timer.Reset();
     this.timer.Start();
     f();
     this.timer.Stop();
     return this.timer.ElapsedTicks;
 }
Exemple #10
0
 public MI_Add(TimedFunction tf, int amount, bool allowDuplicate)
 {
     TF             = tf;
     Amount         = amount >= 1 ? amount : 1;
     AllowDuplicate = allowDuplicate;
 }
Exemple #11
0
    private IEnumerator TimerRoutine(float delay, TimedFunction function)
    {
        for(float t = 0.0f; t < delay; t += Time.deltaTime) {
            yield return null;
        }

        function();
    }
Exemple #12
0
 /// <summary>
 /// Sets a function to be called after some delay
 /// </summary>
 public void SetTimer(float delay, TimedFunction function)
 {
     StartCoroutine(TimerRoutine(delay, function));
 }
Exemple #13
0
    public void SetTimer(TimedFunction function, float delay)
    {
        TimedEvent e = new TimedEvent();
        e.function = function;
        e.delay = delay;
        e.addedTime = Time.time;

        timerList.Add(e);
    }