OLD | NEW |
1 // run_chromium_perf is an application that runs the specified benchmark over CT
's | 1 // run_chromium_perf is an application that runs the specified benchmark over CT
's |
2 // webpage archives. | 2 // webpage archives. |
3 package main | 3 package main |
4 | 4 |
5 import ( | 5 import ( |
6 "encoding/csv" | 6 "encoding/csv" |
| 7 "encoding/json" |
7 "flag" | 8 "flag" |
8 "fmt" | 9 "fmt" |
9 "io/ioutil" | 10 "io/ioutil" |
10 "os" | 11 "os" |
11 "path/filepath" | 12 "path/filepath" |
12 "runtime" | 13 "runtime" |
13 "sync" | 14 "sync" |
14 "time" | 15 "time" |
15 | 16 |
16 "github.com/skia-dev/glog" | 17 "github.com/skia-dev/glog" |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 if pagesetBaseName == util.TIMESTAMP_FILE_NAME || filepath.Ext(pagesetBa
seName) == ".pyc" { | 243 if pagesetBaseName == util.TIMESTAMP_FILE_NAME || filepath.Ext(pagesetBa
seName) == ".pyc" { |
243 // Ignore timestamp files and .pyc files. | 244 // Ignore timestamp files and .pyc files. |
244 return nil | 245 return nil |
245 } | 246 } |
246 | 247 |
247 // Convert the filename into a format consumable by the run_benchmarks | 248 // Convert the filename into a format consumable by the run_benchmarks |
248 // binary. | 249 // binary. |
249 pagesetName := strings.TrimSuffix(pagesetBaseName, filepath.Ext(pagesetB
aseName)) | 250 pagesetName := strings.TrimSuffix(pagesetBaseName, filepath.Ext(pagesetB
aseName)) |
250 pagesetPath := filepath.Join(pathToPagesets, fileInfoName) | 251 pagesetPath := filepath.Join(pathToPagesets, fileInfoName) |
251 | 252 |
| 253 pagesetContent, err := os.Open(pagesetPath) |
| 254 if err != nil { |
| 255 return fmt.Errorf("Could not read %s: %s", pagesetPath, err) |
| 256 } |
| 257 decodedPageset := util.PagesetVars{} |
| 258 if err := json.NewDecoder(pagesetContent).Decode(&decodedPageset); err !
= nil { |
| 259 return fmt.Errorf("Could not JSON decode %s: %s", pagesetPath, e
rr) |
| 260 } |
| 261 |
252 glog.Infof("===== Processing %s for %s =====", pagesetPath, runID) | 262 glog.Infof("===== Processing %s for %s =====", pagesetPath, runID) |
253 | |
254 skutil.LogErr(os.Chdir(pathToPyFiles)) | |
255 args := []string{ | 263 args := []string{ |
256 » » util.BINARY_RUN_BENCHMARK, | 264 » » filepath.Join(util.TelemetryBinariesDir, util.BINARY_RUN_BENCHMA
RK), |
257 » » fmt.Sprintf("%s.%s", *benchmarkName, util.BenchmarksToPagesetNam
e[*benchmarkName]), | 265 » » util.BenchmarksToPagesetName[*benchmarkName], |
258 » » "--page-set-name=" + pagesetName, | |
259 » » "--page-set-base-dir=" + pathToPagesets, | |
260 "--also-run-disabled-tests", | 266 "--also-run-disabled-tests", |
| 267 "--user-agent=" + decodedPageset.UserAgent, |
| 268 "--urls-list=" + decodedPageset.UrlsList, |
| 269 "--archive-data-file=" + decodedPageset.ArchiveDataFile, |
261 } | 270 } |
262 | 271 |
263 // Need to capture output for all benchmarks. | 272 // Need to capture output for all benchmarks. |
264 outputDirArgValue := filepath.Join(localOutputDir, pagesetName) | 273 outputDirArgValue := filepath.Join(localOutputDir, pagesetName) |
265 args = append(args, "--output-dir="+outputDirArgValue) | 274 args = append(args, "--output-dir="+outputDirArgValue) |
266 // Figure out which browser should be used. | 275 // Figure out which browser should be used. |
267 if *targetPlatform == util.PLATFORM_ANDROID { | 276 if *targetPlatform == util.PLATFORM_ANDROID { |
268 if err := util.InstallChromeAPK(chromiumBuildName); err != nil { | 277 if err := util.InstallChromeAPK(chromiumBuildName); err != nil { |
269 return fmt.Errorf("Error while installing APK: %s", err) | 278 return fmt.Errorf("Error while installing APK: %s", err) |
270 } | 279 } |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 return fmt.Errorf("Could not write to %s: %s", csvPath, err) | 392 return fmt.Errorf("Could not write to %s: %s", csvPath, err) |
384 } | 393 } |
385 // Write all values. | 394 // Write all values. |
386 for _, row := range values { | 395 for _, row := range values { |
387 if err := writer.Write(row); err != nil { | 396 if err := writer.Write(row); err != nil { |
388 return fmt.Errorf("Could not write to %s: %s", csvPath,
err) | 397 return fmt.Errorf("Could not write to %s: %s", csvPath,
err) |
389 } | 398 } |
390 } | 399 } |
391 return nil | 400 return nil |
392 } | 401 } |
OLD | NEW |