Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by Joncom

As games become more complicated they perform more slowly. It seems to me a big part of the slow-down occurs from a large amount of checks which take place in various entity update calls. Which begs the question:

Does JavaScript continuously loop through all events checking if the event has fired?

Or does the event itself inform JavaScript when (and only when) it requires attention?

If the former, then events seem no more efficient than Impact already is. If the latter, then much of the code I have could be optimized to use less resources in constant update calls, boosting performance.

It seems like a lot of work to convert what code I have just to test out this theory, so I figured I'd ask around first.

1 decade ago by Joncom

Found this useful page which answered the question quite well.
The browser has [an] inner loop, called Event Loop, which checks the queue and processes events, executes functions etc.
Events are processed asynchronously with the exception of DOM events.
Essensially the question was worded incorrectly, because what I really meant was, is there a way to call a function only when an event takes place, and not have to check if the event has taken place first.

The answer is no, because JavaScript still has to check if the event has taken place, and it does so in the Event Loop.

This is not a viable way to boost performance.
Page 1 of 1
« first « previous next › last »