How can I profile a gradle script

(kiran_anantha) #1

Hello, I have a gradle script that prepares WARs for deployment. It performs various operations to open up a WAR file, add/remove files, signs jars, etc. And it takes a very long time on Windows, much longer than on Linux. Are there any tools to profile the Gradle task other than add println statements for the time taken? Are there any guidelines on which operations are more expensive than others (for example, will invoking ant operations be more expensive, etc) ?

(René Groeschke) #2

besides the --profile option there is no other build in support for profiling your build in gradle. But you can use the any java profiler like yourkit and jprofiler. Usually you need to attach those profiler by adding additional cmdline properties or tweaking rhe gradlew script. from the gradle perspective it would be interesting to see your task implementation that causes these problems. invoking ant isnt expensive in general, but of course it depends on the ant task you’re invoking

cheers, rene

(jonathan_imperial) #3

Hi Rene,

One of the key points of the slowdown seems to be the Windows file system (any read/write operation seems to take ages). Are there any tips surround file operations in gradle, say if we did ant.unzip, would it be faster than say

project.copy {
     from zipTree(zipfile)
    into "dir"