Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Closure compiler advanced - any performance hits?

The online closure compiler is amazing:

http://closure-compiler.appspot.com/home

However, when using the advanced option, will it affect performance of the script at all? IE, will it make it faster or slower in general, or does it depend on the script itself? Or is there no performance hit at all?

I only ask this as some scripts I write will be performance critical, and I know the answer to this question is "try and see" but I'm not very good at running these sorts of tests, I don't know where to start.

like image 429
Tom Gullen Avatar asked Oct 20 '25 13:10

Tom Gullen


1 Answers

Here are two points from the Closure Compilier faq that may interest you.

Does the compiler make any trade-off between my application's execution speed and download code size?

Yes. Any optimizing compiler makes trade-offs. Some size optimizations do introduce small speed overheads. However, the Closure Compiler's developers have been careful not to introduce significant additional runtime. Some of the compiler's optimizations even decrease runtime (see next question).

Does the compiler optimize for speed?

In most cases smaller code is faster code, since download time is usually the most important speed factor in web applications. Optimizations that reduce redundancies speed up the run time of code as well.

So it would seem that it will depend on the code you've written. Could be faster, but there's a chance it could be a little slower. Ultimately, testing will be required.

like image 142
user113716 Avatar answered Oct 22 '25 03:10

user113716