OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 from core import perf_benchmark | 5 from core import perf_benchmark |
6 | 6 |
| 7 from telemetry import story |
7 from telemetry import benchmark | 8 from telemetry import benchmark |
8 from telemetry.core import discover | 9 from telemetry.core import discover |
9 from telemetry.page import page_set | |
10 | 10 |
11 from measurements import skpicture_printer | 11 from measurements import skpicture_printer |
12 | 12 |
13 | 13 |
14 def _MatchPageSetName(page_set_name, page_set_base_dir): | 14 def _MatchPageSetName(story_set_name, story_set_base_dir): |
15 page_sets = [] | 15 story_sets = discover.DiscoverClasses(story_set_base_dir, story_set_base_dir, |
16 page_sets += discover.DiscoverClasses(page_set_base_dir, page_set_base_dir, | 16 story.StorySet).values() |
17 page_set.PageSet, | 17 for s in story_sets: |
18 index_by_class_name=True).values() | 18 if story_set_name == s.Name(): |
19 for p in page_sets: | 19 return s |
20 if page_set_name == p.Name(): | |
21 return p | |
22 return None | 20 return None |
23 | 21 |
24 | 22 |
25 @benchmark.Disabled | 23 @benchmark.Disabled |
26 class SkpicturePrinter(perf_benchmark.PerfBenchmark): | 24 class SkpicturePrinter(perf_benchmark.PerfBenchmark): |
27 @classmethod | 25 @classmethod |
28 def AddBenchmarkCommandLineArgs(cls, parser): | 26 def AddBenchmarkCommandLineArgs(cls, parser): |
29 parser.add_option('--page-set-name', action='store', type='string') | 27 parser.add_option('--page-set-name', action='store', type='string') |
30 parser.add_option('--page-set-base-dir', action='store', type='string') | 28 parser.add_option('--page-set-base-dir', action='store', type='string') |
31 parser.add_option('-s', '--skp-outdir', | 29 parser.add_option('-s', '--skp-outdir', |
32 help='Output directory for the SKP files') | 30 help='Output directory for the SKP files') |
33 @classmethod | 31 @classmethod |
34 def ProcessCommandLineArgs(cls, parser, args): | 32 def ProcessCommandLineArgs(cls, parser, args): |
35 if not args.page_set_name: | 33 if not args.page_set_name: |
36 parser.error('Please specify --page-set-name') | 34 parser.error('Please specify --page-set-name') |
37 if not args.page_set_base_dir: | 35 if not args.page_set_base_dir: |
38 parser.error('Please specify --page-set-base-dir') | 36 parser.error('Please specify --page-set-base-dir') |
39 if not args.skp_outdir: | 37 if not args.skp_outdir: |
40 parser.error('Please specify --skp-outdir') | 38 parser.error('Please specify --skp-outdir') |
41 | 39 |
42 @classmethod | 40 @classmethod |
43 def Name(cls): | 41 def Name(cls): |
44 return 'skpicture_printer' | 42 return 'skpicture_printer' |
45 | 43 |
46 def CreatePageTest(self, options): | 44 def CreatePageTest(self, options): |
47 return skpicture_printer.SkpicturePrinter(options.skp_outdir) | 45 return skpicture_printer.SkpicturePrinter(options.skp_outdir) |
48 | 46 |
49 def CreateStorySet(self, options): | 47 def CreateStorySet(self, options): |
50 page_set_class = _MatchPageSetName(options.page_set_name, | 48 story_set_class = _MatchPageSetName(options.page_set_name, |
51 options.page_set_base_dir) | 49 options.page_set_base_dir) |
52 return page_set_class() | 50 return story_set_class() |
OLD | NEW |