ParkourPenguin I post too much Reputation: 140 Joined: 06 Jul 2014 Posts: 4300
|
Posted: Tue Mar 21, 2017 10:30 am Post subject: |
|
|
Premature optimization is the root of all evil.
If the difference an optimization makes is inconsiderable, the time spent on that optimization was wasted and the complexity that optimization adds is unwarranted. If you are doing something in which creating a timer is a slow and/or costly operation, perhaps you should reconsider using Lua and instead use assembly.
The main problem is the side effects that come from the main thread executing that code in a loop. This freezes the GUI since CE can't respond to messages, but more importantly, the CPU is executing that code as fast as it possibly can. This is almost never required, and as such, your code will make the processor execute more cycles per second than if you had just used a timer.
There's more to programming than performance. Using higher-level abstractions (i.e. while loops and timers) allows you to write safer, more usable, more readable, and/or more maintainable code faster than code using lower-level abstractions.
IMO using a timer wouldn't make a significant difference. If you don't use a timer, the GUI hangs and the CPU is less efficient in most cases, but I really don't care and I don't think most people would care either. It's just another way of doing things. _________________ I don't know where I'm going, but I'll figure it out when I get there.
|
|