Optimization question

Discussion and feedback on Construct 2

Post » Fri Nov 09, 2012 10:37 am

I have an optimization question not covered by the usual performance tutorial.

Does the exporter optimize the math used in event sheets where possible?


For example, if a value is calculated by adding two constants together, will the exporter recognise that these values can not possibly change after export and add them to avoid the unneeded calculation at run-time?


I have a very large number of values initialised in this way, and if such an optimization is possible it could have a significant impact on mobile platforms, so if the exporter doesn't already do this I'd like to create my own tool to do so.
B
24
S
5
G
2
Posts: 104
Reputation: 3,136

Post » Fri Nov 09, 2012 11:27 am

I don't think the exporter would do this, but that's just my intuition. Who knows what @Ashley has cooked up.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Fri Nov 09, 2012 1:57 pm

As it so happens, the exporter does implement a "constant folding" optimisation. If you type the expression 100 + 100, at export time C2 can calculate this and determine it's 200, and not export an addition calculation.

However it's almost completely irrelevant to performance. Don't waste your time worrying about this.

Anything not in the performance tips manual entry probably has negligable effect. Only things likely to have any effect are mentioned in that article, so if it's not mentioned there, you most likely do not need to worry about it at all. You could optimise all the math across an entire large project, and get maybe a 0.01% performance improvement, if you could even measure that accurately. Compare that to reducing the rate of a particles object which could get you a 1% performance improvement (100x better) at almost no effort at all.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Sat Nov 10, 2012 2:46 am

Excellent!

I know it's a fairly insignificant thing, but given the limited capabilities of some of the target platforms I don't think it would have been unreasonable to spend the 10-20 minutes to write myself a quick post-export script which I could then apply to any and every project I ever create. I'm normally all about higher-level algorithmic improvements rather than micro-optimization, but when something can so easily improve every project with very minimal work I feel it's definitely worthy of pursuit.

Even better that the exporter already handles this and I don't need to do the work at all though!
B
24
S
5
G
2
Posts: 104
Reputation: 3,136


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 11 guests