org.gradle.performance.results.CrossVersionPerformanceTestHistory 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.performance.results;
import com.google.common.base.Function;
import com.google.common.collect.Lists;
import org.gradle.api.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class CrossVersionPerformanceTestHistory implements PerformanceTestHistory {
private final String name;
private final List versions;
private final List branches;
private final List newestFirst;
private List oldestFirst;
private List knownVersions;
public CrossVersionPerformanceTestHistory(String name, List versions, List branches, List newestFirst) {
this.name = name;
this.versions = versions;
this.branches = branches;
this.newestFirst = newestFirst;
}
@Override
public String getId() {
return name.replaceAll("\\s+", "-");
}
@Override
public String getDisplayName() {
return name;
}
public List getBaselineVersions() {
return versions;
}
public List getBranches() {
return branches;
}
public List getKnownVersions() {
if (knownVersions == null) {
ArrayList result = new ArrayList();
result.addAll(versions);
result.addAll(branches);
knownVersions = result;
}
return knownVersions;
}
/**
* Returns results from most recent to least recent.
*/
public List getResults() {
return newestFirst;
}
/**
* Returns results from least recent to most recent.
*/
public List getResultsOldestFirst() {
if (oldestFirst == null) {
oldestFirst = new ArrayList(newestFirst);
Collections.reverse(oldestFirst);
}
return oldestFirst;
}
@Override
public List getExecutions() {
return Lists.transform(getResults(), new Function() {
public PerformanceTestExecution apply(final CrossVersionPerformanceResults result) {
return new KnownVersionsPerformanceTestExecution(result);
}
});
}
@Override
public List extends ScenarioDefinition> getScenarios() {
if (newestFirst.isEmpty()) {
return Collections.emptyList();
}
final CrossVersionPerformanceResults mostRecent = newestFirst.get(0);
return Lists.transform(getKnownVersions(), new Function() {
@Override
public ScenarioDefinition apply(final String input) {
return new ScenarioDefinition() {
@Override
public String getDisplayName() {
return input;
}
@Override
public String getTestProject() {
return mostRecent.getTestProject();
}
@Override
public List getTasks() {
return mostRecent.getTasks();
}
@Override
public List getArgs() {
return mostRecent.getArgs();
}
@Nullable
@Override
public List getGradleOpts() {
return mostRecent.getGradleOpts();
}
@Nullable
@Override
public Boolean getDaemon() {
return mostRecent.getDaemon();
}
};
}
});
}
@Override
public int getScenarioCount() {
return getKnownVersions().size();
}
@Override
public List getScenarioLabels() {
return getKnownVersions();
}
private class KnownVersionsPerformanceTestExecution implements PerformanceTestExecution {
private final CrossVersionPerformanceResults result;
public KnownVersionsPerformanceTestExecution(CrossVersionPerformanceResults result) {
this.result = result;
}
public String getVersionUnderTest() {
return result.getVersionUnderTest();
}
public String getVcsBranch() {
return result.getVcsBranch();
}
public long getStartTime() {
return result.getStartTime();
}
@Override
public long getEndTime() {
return result.getEndTime();
}
@Override
public List getVcsCommits() {
return result.getVcsCommits();
}
public List getScenarios() {
return Lists.transform(getKnownVersions(), new Function() {
public MeasuredOperationList apply(String version) {
return result.version(version).getResults();
}
});
}
@Override
public String getOperatingSystem() {
return result.getOperatingSystem();
}
@Override
public String getJvm() {
return result.getJvm();
}
@Nullable
@Override
public List getArgs() {
return result.getArgs();
}
@Nullable
@Override
public String getTestProject() {
return result.getTestProject();
}
@Nullable
@Override
public List getTasks() {
return result.getTasks();
}
@Nullable
@Override
public List getGradleOpts() {
return result.getGradleOpts();
}
@Nullable
@Override
public Boolean getDaemon() {
return result.getDaemon();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy