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(); }
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(); }
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."); }
public MI_Replace(TimedFunction oldTF, TimedFunction newTF, bool replaceAll) : this(oldTF, newTF, replaceAll, -1) { }
public MI_Remove(TimedFunction tf, bool removeAll, int amount) { TF = tf; RemoveAll = removeAll; this.amount = (amount >= 0) ? amount : -1; }
public MI_Remove(TimedFunction tf, bool removeAll) : this(tf, removeAll, -1) { }
private long CallWithTimer(TimedFunction f) { this.timer.Reset(); this.timer.Start(); f(); this.timer.Stop(); return this.timer.ElapsedTicks; }
public MI_Add(TimedFunction tf, int amount, bool allowDuplicate) { TF = tf; Amount = amount >= 1 ? amount : 1; AllowDuplicate = allowDuplicate; }
private IEnumerator TimerRoutine(float delay, TimedFunction function) { for(float t = 0.0f; t < delay; t += Time.deltaTime) { yield return null; } function(); }
/// <summary> /// Sets a function to be called after some delay /// </summary> public void SetTimer(float delay, TimedFunction function) { StartCoroutine(TimerRoutine(delay, function)); }