Is there any performance benefit to using scripting in some cases?

From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin

    Just curious if there is any performance benefit in using scripts in some cases.

    For example, loops, and iterating through many instances.

    Would be interesting to see a blog post of benchmarks similar to what has been done previously.

    in the ghost shooter js example, there is a set of utility functions.

    Would it be possible to call a js utility function in an event condition? Something like that would be very useful i think.

    I think the easiest way to test this would be to benchmark the two versions of Ghost Shooter against each other (though I'm not sure if they're 100% the same game)

    Well the test needs to be on something that is normally cpu intensive in events, for each for example. Or something that is less performant in events, like say moving a object out of a solid.

    It completely depends on what you're doing and what you're comparing it to.

    Running events has relatively high overhead compared to JS code, so if you have event-heavy code doing things like intensive calculations with lots of loops, the equivalent JS may be faster.

    On the other hand, some parts of the Construct engine are extremely well optimised, and have been carefully honed over the years with all our long experience of performance testing JS code. If you write your own scripts to do your own code instead of using the engine, it could well be significantly slower, unless you put in the same effort we have. One example off the top of my head is if you ignore Construct's collision engine and write your own custom one in script, it could well be significantly slower. Not only could it be slower in absolute terms (slower when doing the same work), but it could be slower in algorithmic terms (as in getting exponentially slower as your game gets bigger, whereas Construct's engine is highly scalable and can keep doing about the same amount of work no matter how much bigger the game gets).

    As ever performance benchmarks are the only way to know for sure.

    Running events has relatively high overhead compared to JS code

    Can you expound upon what this means a bit further? Perhaps an example of such an overhead.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads

    Running events fundamentally involves more work than running pure JavaScript code. For example running a list of actions involves a loop, and if you write JavaScript code that just does a series of tasks without a loop, then it has less overhead.

    In many cases the overhead of the event engine doesn't matter though, and as I mentioned many aspects of the engine are extremely well optimized and would be difficult to match in your own JavaScript code, e.g. pathfinding.

    If you want to know the exact performance difference, as I said, you can get a very precise answer by measuring it yourself.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)