Index: ct/go/worker_scripts/run_chromium_perf/main.go |
diff --git a/ct/go/worker_scripts/run_chromium_perf/main.go b/ct/go/worker_scripts/run_chromium_perf/main.go |
index 7282c4f602e31e597d860cacbe7adbac82035bc0..4dec26ed4a7b9b67652508c0829d8b69aad0fb69 100644 |
--- a/ct/go/worker_scripts/run_chromium_perf/main.go |
+++ b/ct/go/worker_scripts/run_chromium_perf/main.go |
@@ -6,6 +6,7 @@ import ( |
"encoding/csv" |
"flag" |
"fmt" |
+ "io" |
"io/ioutil" |
"os" |
"path/filepath" |
@@ -34,6 +35,7 @@ var ( |
pagesetType = flag.String("pageset_type", util.PAGESET_TYPE_MOBILE_10k, "The type of pagesets to create from the Alexa CSV list. Eg: 10k, Mobile10k, All.") |
chromiumBuildNoPatch = flag.String("chromium_build_nopatch", "", "The chromium build to use for the nopatch run.") |
chromiumBuildWithPatch = flag.String("chromium_build_withpatch", "", "The chromium build to use for the withpatch run.") |
+ runID = flag.String("run_id", "", "The unique run id (typically requester + timestamp).") |
runIDNoPatch = flag.String("run_id_nopatch", "", "The unique run id (typically requester + timestamp) for the nopatch run.") |
runIDWithPatch = flag.String("run_id_withpatch", "", "The unique run id (typically requester + timestamp) for the withpatch run.") |
benchmarkName = flag.String("benchmark_name", "", "The telemetry benchmark to run on this worker.") |
@@ -113,6 +115,38 @@ func main() { |
return |
} |
+ // Download the benchmark patch for this run from Google storage. |
+ benchmarkPatchName := *runID + ".benchmark.patch" |
+ benchmarkPatchLocalPath := filepath.Join(os.TempDir(), benchmarkPatchName) |
+ remoteDir := filepath.Join(util.ChromiumPerfRunsDir, *runID) |
+ benchmarkPatchRemotePath := filepath.Join(remoteDir, benchmarkPatchName) |
+ respBody, err := gs.GetRemoteFileContents(benchmarkPatchRemotePath) |
+ if err != nil { |
+ glog.Errorf("Could not fetch %s: %s", benchmarkPatchRemotePath, err) |
+ return |
+ } |
+ defer skutil.Close(respBody) |
+ out, err := os.Create(benchmarkPatchLocalPath) |
dogben
2015/10/20 15:17:26
Seems like you could use os.WriteFile. https://gol
rmistry
2015/10/20 17:47:48
Done.
|
+ if err != nil { |
+ glog.Errorf("Unable to create file %s: %s", benchmarkPatchLocalPath, err) |
+ return |
+ } |
+ defer skutil.Close(out) |
+ defer skutil.Remove(benchmarkPatchLocalPath) |
+ if _, err = io.Copy(out, respBody); err != nil { |
+ glog.Error(err) |
+ return |
+ } |
+ // Apply benchmark patch to the local chromium checkout. |
+ benchmarkPatchFile, _ := os.Open(benchmarkPatchLocalPath) |
dogben
2015/10/20 15:17:26
Use os.Stat. https://golang.org/pkg/os/#Stat
(Or d
rmistry
2015/10/20 17:47:48
Done.
dogben
2015/10/20 18:14:08
Nit: You actually have the size from buf above, so
rmistry
2015/10/21 12:32:47
Done.
|
+ benchmarkPatchFileInfo, _ := benchmarkPatchFile.Stat() |
+ if benchmarkPatchFileInfo.Size() > 10 { |
+ if err := util.ApplyPatch(benchmarkPatchLocalPath, util.ChromiumSrcDir); err != nil { |
+ glog.Errorf("Could not apply Telemetry's patch in %s: %s", util.ChromiumSrcDir, err) |
+ return |
+ } |
+ } |
+ |
// Download the specified chromium builds. |
for _, chromiumBuild := range []string{*chromiumBuildNoPatch, *chromiumBuildWithPatch} { |
if err := gs.DownloadChromiumBuild(chromiumBuild); err != nil { |
@@ -253,9 +287,14 @@ func runBenchmark(fileInfoName, pathToPagesets, pathToPyFiles, localOutputDir, c |
} |
glog.Infof("===== Processing %s for %s =====", pagesetPath, runID) |
+ pagesetName, present := util.BenchmarksToPagesetName[*benchmarkName] |
+ if !present { |
+ // If it is custom benchmark use the entered benchmark name. |
+ pagesetName = *benchmarkName |
+ } |
args := []string{ |
filepath.Join(util.TelemetryBinariesDir, util.BINARY_RUN_BENCHMARK), |
- util.BenchmarksToPagesetName[*benchmarkName], |
+ pagesetName, |
"--also-run-disabled-tests", |
"--user-agent=" + decodedPageset.UserAgent, |
"--urls-list=" + decodedPageset.UrlsList, |