Profiling Gradle build

I am trying to speed-up a gradle build (v.3.4.1) and there are a few things I don’t understand.

Running the test task together with --profile switch i get different times reported:
console - 6 min
test report - 3 min
profile report for :test task - 6 min
Where are these time differences coming from?

I see lot of Gradle Test Executors.
Looks like a new one is started for each test class. Is this normal? How can I profile the build when i have so many different processes started?

14:58:04.261 [INFO] [org.gradle.process.internal.DefaultExecHandle] Starting process ‘Gradle Test Executor 141’. Working directory: C:\Users\module Command: C:\Program Files\Java\jdk1.8.0_73\bin\java.exe -Djava.security.manager=worker.org.gradle.process.internal.worker.child.BootstrapSecurityManager -javaagent:build/tmp/expandedArchives/org.jacoco.agent-0.7.8.jar_bylmp89qn2yodgtt6tdi0j6me/jacocoagent.jar=destfile=build/jacoco/test.exec,append=true,inclnolocationclasses=false,dumponexit=true,output=file,jmx=false -Xms256m -Xmx512m -Dfile.encoding=windows-1252 -Duser.country=US -Duser.language=en -Duser.variant -ea -cp C:\Users~.gradle\caches\3.4.1\workerMain\gradle-worker.jar worker.org.gradle.process.internal.worker.GradleWorkerMain ‘Gradle Test Executor 141’
14:58:04.261 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: STARTING
14:58:04.261 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Waiting until process started: Gradle Test Executor 141.
14:58:04.263 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: STARTED
14:58:04.263 [DEBUG] [org.gradle.process.internal.ExecHandleRunner] waiting until streams are handled…
14:58:04.263 [INFO] [org.gradle.process.internal.DefaultExecHandle] Successfully started process ‘Gradle Test Executor 141’
14:58:04.651 [DEBUG] [org.gradle.internal.remote.internal.inet.TcpIncomingConnector] Accepted connection from /127.0.0.1:55045 to /127.0.0.1:55044.
14:58:04.651 [DEBUG] [org.gradle.process.internal.worker.DefaultWorkerProcess] Received connection org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection@38c9ffd4 from Gradle Test Executor 141
14:58:04.705 [DEBUG] [org.gradle.process.internal.worker.child.ActionExecutionWorker] Starting Gradle Test Executor 141.
14:58:04.735 [INFO] [org.gradle.internal.nativeintegration.services.NativeServices] Initialized native services in: C:\Users~.gradle\native
14:58:04.735 [INFO] [org.gradle.api.internal.tasks.testing.worker.TestWorker] Gradle Test Executor 141 started executing tests.
14:58:04.829 [DEBUG] [TestEventLogger] Gradle Test Executor 141 STARTED
14:58:04.831 [DEBUG] [org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor] Executing test class com.MyClass
14:58:04.832 [DEBUG] [TestEventLogger] com.MyClass STARTED
14:58:04.874 [DEBUG] [TestEventLogger] com.MyClassr > test1 STARTED
14:58:04.881 [DEBUG] [TestEventLogger] com.MyClass > test1 PASSED
14:58:04.881 [DEBUG] [TestEventLogger] com.MyClass PASSED
14:58:04.882 [INFO] [org.gradle.api.internal.tasks.testing.worker.TestWorker] Gradle Test Executor 141 finished executing tests.
14:58:04.882 [DEBUG] [TestEventLogger] Gradle Test Executor 141 PASSED
14:58:04.884 [DEBUG] [org.gradle.process.internal.worker.child.ActionExecutionWorker] Completed Gradle Test Executor 141.
14:58:04.964 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: SUCCEEDED
14:58:04.964 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Process ‘Gradle Test Executor 141’ finished with exit value 0 (state: SUCCEEDED)

My intention is to speed-up the tests in gradle, as in IDEA the same tests run in under 2 minutes. Any help appreciated!

running each test in a separate jvm is not normal. by default gradle uses on process per test task.
check if you have changed the default behavior via Test#forkEvery property.

cheers,
rené

I discovered that a gradle plugin was configuring the project with

test {
forkEvery = 1
}
Which explains why I had so many Gradle Test Executors. I put it back to the default value of 0, and test time improved a lot.