View Single Post
01-18-12, 07:55 AM   #3
Barjack
A Black Drake
AddOn Author - Click to view addons
Join Date: Apr 2009
Posts: 89
My intuition would be that function call overhead makes a single OnUpdate function (marginally) more efficient--though I haven't actually tested this.

But since OnUpdate scripts on visible frames are called once per frame regardless of whether or not your condition in that function evaluates true or false, the result in either case is 3 mathematical operations per frame (adding time elapsed to a "time since last update" for each type of thing), 3 comparisons per frame (comparing total time elapsed against your delay for that type), but 1-3 function calls per frame depending on the number of functions you're using.

Again though, this is all just assumptions on my part. I've not actually benchmarked the difference and there may very well be considerations I'm overlooking. And if frames are ever being hidden and their OnUpdate scripts therefore skipped, that may make a difference as well.

Last edited by Barjack : 01-18-12 at 07:57 AM.
  Reply With Quote