You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geode.apache.org by Jared Stewart <js...@pivotal.io> on 2016/09/20 22:23:42 UTC

Speed up your Gradle tasks!

I wanted to share a tip with everyone that may speed up your build and test execution times if you don’t already use it.  Before we can speed up these tasks, it would be helpful to measure their baseline.  This can be done by adding the --profile flag, e.g. executing “gradle test --profile”.  The --profile flag will generate an html report under ./build/reports/profile/ that gives you an explanation of exactly where Gradle is spending its time.  Here is my test report summary:

Description	Duration
Total Build Time	4m32.03s
Startup	0.600s
Settings and BuildSrc	0.037s
Loading Projects	0.009s
Configuring Projects	0.269s
Task Execution	4m30.90s

You can also click into the ‘Task Execution’ tab of the html page to get more fine grained details.

Now on to the tip.  Our Gradle build and test executions depend on building the source code for each of our submodules.  By default this is done sequentially, but we can tell Gradle to execute tasks from independent submodules in parallel by adding the --parallel flag. Let’s see if this speeds up our build time.  Here is my test report summary from running “gradle test --profile --parallel”:

Description	Duration
Total Build Time	2m8.84s
Startup	0.608s
Settings and BuildSrc	0.054s
Loading Projects	0.006s
Configuring Projects	0.229s
Task Execution	5m0.68s

So the parallel flag cut our build time in half!  In case you want more details about parallel task execution in Gradle, see this section of the User Guide https://docs.gradle.org/current/userguide/multi_project_builds.html#sec:parallel_execution <https://docs.gradle.org/current/userguide/multi_project_builds.html#sec:parallel_execution>.