diff options
Diffstat (limited to 'src')
5 files changed, 40 insertions, 9 deletions
diff --git a/src/tools/benchmark/java/com/google/devtools/build/benchmark/BazelBuilder.java b/src/tools/benchmark/java/com/google/devtools/build/benchmark/BazelBuilder.java index 7d6daf9fbc..6d49b7b6bb 100644 --- a/src/tools/benchmark/java/com/google/devtools/build/benchmark/BazelBuilder.java +++ b/src/tools/benchmark/java/com/google/devtools/build/benchmark/BazelBuilder.java @@ -142,6 +142,14 @@ class BazelBuilder implements Builder { "--before", dateFilter.getToString(), "--pretty=format:%H", "--reverse"); } + @Override + public ImmutableList<String> getDatetimeForCodeVersions(ImmutableList<String> codeVersions) + throws CommandException { + return getListOfOutputFromCommandWithAdditionalParam(codeVersions, + "git", "show", "-s", + "--date=iso", "--pretty=format:%cd", "--date=format:%Y-%m-%d %H:%M:%S"); + } + void prepareFromGitRepo(String gitRepo) throws IOException, CommandException { if (builderDir.toFile().exists() && !builderDir.toFile().isDirectory()) { try { @@ -171,4 +179,13 @@ class BazelBuilder implements Builder { String output = new String(result.getStdout(), UTF_8).trim(); return ImmutableList.copyOf(output.split("\n")); } + + private ImmutableList<String> getListOfOutputFromCommandWithAdditionalParam( + ImmutableList<String> additionalParam, String... command) throws CommandException{ + ImmutableList<String> commandList = + ImmutableList.<String>builder().add(command).addAll(additionalParam).build(); + String[] finalCommand = commandList.toArray(new String[0]); + + return getListOfOutputFromCommand(finalCommand); + } } diff --git a/src/tools/benchmark/java/com/google/devtools/build/benchmark/BuildGroupRunner.java b/src/tools/benchmark/java/com/google/devtools/build/benchmark/BuildGroupRunner.java index 4df2611ba3..82d4d3b490 100644 --- a/src/tools/benchmark/java/com/google/devtools/build/benchmark/BuildGroupRunner.java +++ b/src/tools/benchmark/java/com/google/devtools/build/benchmark/BuildGroupRunner.java @@ -45,15 +45,16 @@ class BuildGroupRunner { prepareBuilder(); System.out.println("Done preparing builder."); - // Get code versions (commit hashtag for Bazel) + // Get code versions (commit hashtag for Bazel) and datetimes ImmutableList<String> codeVersions = buildCase.getCodeVersions(builder, opt); + ImmutableList<String> datetimes = builder.getDatetimeForCodeVersions(codeVersions); System.out.println("Ready to run benchmark for the following versions:"); for (String version : codeVersions) { System.out.println(version); } BuildGroupResult.Builder buildGroupResultBuilder = - getBuildGroupResultBuilder(buildTargetConfigs, buildEnvConfigs, codeVersions); + getBuildGroupResultBuilder(buildTargetConfigs, buildEnvConfigs, codeVersions, datetimes); boolean lastIsIncremental = true; for (int versionIndex = 0; versionIndex < codeVersions.size(); ++versionIndex) { @@ -144,13 +145,14 @@ class BuildGroupRunner { private static BuildGroupResult.Builder getBuildGroupResultBuilder( ImmutableList<BuildTargetConfig> buildTargetConfigs, ImmutableList<BuildEnvConfig> buildEnvConfigs, - ImmutableList<String> codeVersions) { + ImmutableList<String> codeVersions, + ImmutableList<String> datetimes) { // Initialize a BuildGroupResult object to preserve array length BuildGroupResult.Builder buildGroupResultBuilder = BuildGroupResult.newBuilder(); for (BuildTargetConfig targetConfig : buildTargetConfigs) { BuildTargetResult.Builder targetBuilder = BuildTargetResult.newBuilder().setBuildTargetConfig(targetConfig); - prepareBuildEnvConfigs(buildEnvConfigs, codeVersions, targetBuilder); + prepareBuildEnvConfigs(buildEnvConfigs, targetBuilder, codeVersions, datetimes); buildGroupResultBuilder.addBuildTargetResults(targetBuilder.build()); } return buildGroupResultBuilder; @@ -158,12 +160,17 @@ class BuildGroupRunner { private static void prepareBuildEnvConfigs( ImmutableList<BuildEnvConfig> buildEnvConfigs, + BuildTargetResult.Builder targetBuilder, ImmutableList<String> codeVersions, - BuildTargetResult.Builder targetBuilder) { + ImmutableList<String> datetimes) { for (BuildEnvConfig envConfig : buildEnvConfigs) { BuildEnvResult.Builder envBuilder = BuildEnvResult.newBuilder().setConfig(envConfig); - for (String version : codeVersions) { - envBuilder.addResults(SingleBuildResult.newBuilder().setCodeVersion(version).build()); + for (int i = 0; i < codeVersions.size(); ++i) { + envBuilder.addResults( + SingleBuildResult.newBuilder() + .setCodeVersion(codeVersions.get(i)) + .setDatetime(datetimes.get(i)) + .build()); } targetBuilder.addBuildEnvResults(envBuilder.build()); } diff --git a/src/tools/benchmark/java/com/google/devtools/build/benchmark/Builder.java b/src/tools/benchmark/java/com/google/devtools/build/benchmark/Builder.java index 9d8bdac3c6..8409a2c97e 100644 --- a/src/tools/benchmark/java/com/google/devtools/build/benchmark/Builder.java +++ b/src/tools/benchmark/java/com/google/devtools/build/benchmark/Builder.java @@ -36,6 +36,10 @@ interface Builder { ImmutableList<String> getCodeVersionsBetweenDates(DateFilter dateFilter) throws CommandException; + /** Return the datetime of all {@code codeVersions} */ + ImmutableList<String> getDatetimeForCodeVersions(ImmutableList<String> codeVersions) + throws CommandException; + /** Returns a command for build under specific config. */ ImmutableList<String> getCommandFromConfig( BuildTargetConfig targetConfig, BuildEnvConfig envConfig); diff --git a/src/tools/benchmark/java/com/google/devtools/build/benchmark/build_data.proto b/src/tools/benchmark/java/com/google/devtools/build/benchmark/build_data.proto index f43ecdfea1..97e35702f4 100644 --- a/src/tools/benchmark/java/com/google/devtools/build/benchmark/build_data.proto +++ b/src/tools/benchmark/java/com/google/devtools/build/benchmark/build_data.proto @@ -30,7 +30,8 @@ message BuildEnvConfig { // results are used for running benchmark for several times for now message SingleBuildResult { string code_version = 1; - repeated double results = 2; + string datetime = 2; + repeated double results = 3; } // Build results for a specific environment config diff --git a/src/tools/benchmark/webapp/draw_chart.js b/src/tools/benchmark/webapp/draw_chart.js index a984fc5e4a..71155d03d4 100644 --- a/src/tools/benchmark/webapp/draw_chart.js +++ b/src/tools/benchmark/webapp/draw_chart.js @@ -64,6 +64,8 @@ function initChartData (buildTargetResults, chart, tableData, options) { // Options for each chart (including title) options[i] = { title: buildTargetResults[i].buildTargetConfig.description, + vAxis: { title: 'Elapsed time (s)' }, + hAxis: { title: 'Changes' }, tooltip: { isHtml: true, trigger: 'both' }, intervals: { style: 'bars' }, chartArea: { width: '70%' } @@ -131,7 +133,7 @@ function addColumnsFromBuildEnv (lineChart, buildEnvResults) { */ function addRowsFromData (lineChart, buildEnvResults) { for (let j = 0; j < buildEnvResults[0].results.length; ++j) { - const row = [buildEnvResults[0].results[j].codeVersion.substr(0, 10)]; + const row = [buildEnvResults[0].results[j].datetime]; for (let buildEnvResult of buildEnvResults) { const singleBuildResult = buildEnvResult.results[j]; |