/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ def recordings = files() allprojects { plugins.withType(JavaPlugin) { project.ext { testOptions += [ [propName: 'tests.profile', value: false, description: "Enable Java Flight Recorder profiling."] ] } if (resolvedTestOption("tests.profile").toBoolean()) { if (rootProject.hasJavaFlightRecorder) { tasks.withType(Test) { jvmArgs("-XX:StartFlightRecording=dumponexit=true,maxsize=250M,settings=" + rootProject.file("gradle/testing/profiling.jfc"), "-XX:+UnlockDiagnosticVMOptions", "-XX:+DebugNonSafepoints") // delete any previous profile results doFirst { project.delete fileTree(dir: workingDir, include: '*.jfr') } doLast { recordings = recordings.plus fileTree(dir: workingDir, include: '*.jfr') } } } else { throw new GradleException('Module jdk.jfr is not available; Java Flight Recorder profiles cannot be enabled.') } } } } gradle.buildFinished { if (!recordings.isEmpty()) { def pr = org.apache.lucene.gradle.ProfileResults; pr.printReport(recordings.getFiles().collect { it.toString() }, propertyOrDefault(pr.MODE_KEY, pr.MODE_DEFAULT) as String, Integer.parseInt(propertyOrDefault(pr.STACKSIZE_KEY, pr.STACKSIZE_DEFAULT)), Integer.parseInt(propertyOrDefault(pr.COUNT_KEY, pr.COUNT_DEFAULT)), Boolean.parseBoolean(propertyOrDefault(pr.LINENUMBERS_KEY, pr.LINENUMBERS_DEFAULT))) } }