Remove the first result in benchmark, since it's slower than others.
And a little refactor.
MOS_MIGRATED_REVID=148446876
@@ -72,6 +72,30 @@ class BuildGroupRunner {
// Target config
for (int targetIndex = 0; targetIndex < buildTargetConfigs.size(); ++targetIndex) {
+ lastIsIncremental = runForConfigAndReturnLastIsIncremental(
+ buildGroupResultBuilder,
+ buildCase,
+ buildBinary,
+ envConfig,
+ buildTargetConfigs,
+ versionIndex, envIndex, targetIndex,
+ lastIsIncremental, (t == 0 && envIndex == 0 && targetIndex == 0));
+ }
+ }
+ }
+ }
+
+ return buildGroupResultBuilder.build();
+ }
+
+ private boolean runForConfigAndReturnLastIsIncremental(
+ BuildGroupResult.Builder buildGroupResultBuilder,
+ BuildCase buildCase,
+ Path buildBinary,
+ BuildEnvConfig envConfig,
+ ImmutableList<BuildTargetConfig> buildTargetConfigs,
+ int versionIndex, int envIndex, int targetIndex,
+ boolean lastIsIncremental, boolean removeFirstResult) throws IOException, CommandException{
BuildTargetConfig targetConfig = buildTargetConfigs.get(targetIndex);
System.out.println(targetConfig.getDescription());
@@ -87,16 +111,10 @@ class BuildGroupRunner {
}
lastIsIncremental = envConfig.getIncremental();
- // Builder's clean method
- if (envConfig.getCleanBeforeBuild()) {
- builder.clean();
+ if (removeFirstResult) {
+ buildTargetAndGetElapsedTime(buildBinary, envConfig, targetConfig);
}
-
- // Run build
- double elapsedTime =
- builder.buildAndGetElapsedTime(
- buildBinary, builder.getCommandFromConfig(targetConfig, envConfig));
- System.out.println(elapsedTime);
+ double elapsedTime = buildTargetAndGetElapsedTime(buildBinary, envConfig, targetConfig);
// Store result
buildGroupResultBuilder
@@ -104,12 +122,23 @@ class BuildGroupRunner {
.getBuildEnvResultsBuilder(envIndex)
.getResultsBuilder(versionIndex)
.addResults(elapsedTime);
+ return lastIsIncremental;
}
- }
- }
+
+ private double buildTargetAndGetElapsedTime(
+ Path buildBinary, BuildEnvConfig envConfig, BuildTargetConfig targetConfig)
+ throws CommandException {
+ // Builder's clean method
+ if (envConfig.getCleanBeforeBuild()) {
+ builder.clean();
}
- return buildGroupResultBuilder.build();
+ // Run build
+ double elapsedTime =
+ builder.buildAndGetElapsedTime(
+ buildBinary, builder.getCommandFromConfig(targetConfig, envConfig));
+ System.out.println(elapsedTime);
+ return elapsedTime;
}
private static BuildGroupResult.Builder getBuildGroupResultBuilder(
