org.gradle.profile.ProfileReportRendererTest.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gradle-api Show documentation
Show all versions of gradle-api Show documentation
Gradle 6.9.1 API redistribution.
/*
* Copyright 2013 the original author or authors.
*
* Licensed 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.
*/
package org.gradle.profile
import org.gradle.StartParameter
import org.gradle.api.tasks.TaskState
import org.gradle.test.fixtures.file.TestNameTestDirectoryProvider
import org.junit.Rule
import spock.lang.Specification
import static org.gradle.util.TextUtil.toPlatformLineSeparators
class ProfileReportRendererTest extends Specification {
@Rule TestNameTestDirectoryProvider temp = new TestNameTestDirectoryProvider(getClass())
def "renders report"() {
def model = new BuildProfile(new StartParameter())
def file = temp.file("report.html")
model.profilingStarted = time(12, 20, 0)
model.buildStarted = time(12, 20, 0, 700)
model.settingsEvaluated = time(12, 20, 3)
model.projectsLoaded = time(12, 20, 6)
model.buildFinished = time(12, 35, 30)
model.getDependencySetProfile("compile").start = time(12, 22, 0)
model.getDependencySetProfile("compile").finish = time(12, 23, 30)
model.getDependencySetProfile("runtime").start = time(12, 24, 0)
model.getDependencySetProfile("runtime").finish = time(12, 24, 30)
model.getTransformationProfile("some transform").start(time(12, 22, 0)).setFinish(time(12, 22, 12))
model.getTransformationProfile("some other transform").start(time(12, 23, 0)).setFinish(time(12, 23, 19))
model.getProjectProfile("a").configurationOperation.start = time(12, 20, 7)
model.getProjectProfile("a").configurationOperation.finish = time(12, 20, 10)
model.getProjectProfile("a").getTaskProfile("a:foo").completed(Stub(TaskState)).setStart(time(12, 25, 0)).setFinish(time(12, 26, 30))
model.getProjectProfile("a").getTaskProfile("a:bar").completed(Stub(TaskState)).setStart(time(12, 26, 30)).setFinish(time(12, 27, 0))
model.getProjectProfile("b").configurationOperation.start = time(12, 20, 10)
model.getProjectProfile("b").configurationOperation.finish = time(12, 20, 15)
//let's say they run in parallel, hence same start time
model.getProjectProfile("b").getTaskProfile("b:foo").completed(Stub(TaskState)).setStart(time(12, 27, 0)).setFinish(time(12, 29, 30))
model.getProjectProfile("b").getTaskProfile("b:bar").completed(Stub(TaskState)).setStart(time(12, 27, 0)).setFinish(time(12, 29, 0))
when:
new ProfileReportRenderer().writeTo(model, file)
then:
file.text.contains(toPlatformLineSeparators("""
Profile report
Profile report
Profiled build: (no tasks specified)
Started on: 2010/02/05 - 12:20:00
Summary
Description
Duration
Total Build Time
15m30.00s
Startup
0.700s
Settings and buildSrc
2.300s
Loading Projects
3.000s
Configuring Projects
8.000s
Artifact Transforms
31.000s
Task Execution
6m30.00s
Configuration
Project
Duration
All projects
8.000s
b
5.000s
a
3.000s
Dependency Resolution
Dependencies
Duration
All dependencies
2m0.00s
compile
1m30.00s
runtime
30.000s
Artifact Transforms
Transform
Duration
All transforms
31.000s
some other transform
19.000s
some transform
12.000s
Task Execution
Task
Duration
Result
b
4m30.00s
(total)
b:foo
2m30.00s
Did No Work
b:bar
2m0.00s
Did No Work
a
2m0.00s
(total)
a:foo
1m30.00s
Did No Work
a:bar
30.000s
Did No Work
"""))
}
private static long time(int hour, int mins, int secs, int ms = 0) {
def cal = new GregorianCalendar(2010, 1, 5, hour, mins, secs)
cal.add(Calendar.MILLISECOND, ms)
cal.getTimeInMillis()
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy