OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 * | 6 * |
7 */ | 7 */ |
8 | 8 |
9 #include <VisualBench/VisualBenchmarkStream.h> | 9 #include <VisualBench/VisualBenchmarkStream.h> |
| 10 #include "CpuWrappedBenchmark.h" |
10 #include "GMBench.h" | 11 #include "GMBench.h" |
11 #include "SkOSFile.h" | 12 #include "SkOSFile.h" |
12 #include "SkPictureRecorder.h" | 13 #include "SkPictureRecorder.h" |
13 #include "SkStream.h" | 14 #include "SkStream.h" |
14 #include "VisualSKPBench.h" | 15 #include "VisualSKPBench.h" |
15 | 16 |
| 17 DEFINE_bool(cpu, false, "Run in CPU mode?"); |
16 DEFINE_string2(match, m, nullptr, | 18 DEFINE_string2(match, m, nullptr, |
17 "[~][^]substring[$] [...] of bench name to run.\n" | 19 "[~][^]substring[$] [...] of bench name to run.\n" |
18 "Multiple matches may be separated by spaces.\n" | 20 "Multiple matches may be separated by spaces.\n" |
19 "~ causes a matching bench to always be skipped\n" | 21 "~ causes a matching bench to always be skipped\n" |
20 "^ requires the start of the bench to match\n" | 22 "^ requires the start of the bench to match\n" |
21 "$ requires the end of the bench to match\n" | 23 "$ requires the end of the bench to match\n" |
22 "^ and $ requires an exact match\n" | 24 "^ and $ requires an exact match\n" |
23 "If a bench does not match any list entry,\n" | 25 "If a bench does not match any list entry,\n" |
24 "it is skipped unless some list entry starts with ~"); | 26 "it is skipped unless some list entry starts with ~"); |
25 DEFINE_string(skps, "skps", "Directory to read skps from."); | 27 DEFINE_string(skps, "skps", "Directory to read skps from."); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 } | 67 } |
66 | 68 |
67 Benchmark* VisualBenchmarkStream::next() { | 69 Benchmark* VisualBenchmarkStream::next() { |
68 Benchmark* bench; | 70 Benchmark* bench; |
69 // skips non matching benches | 71 // skips non matching benches |
70 while ((bench = this->innerNext()) && | 72 while ((bench = this->innerNext()) && |
71 (SkCommandLineFlags::ShouldSkip(FLAGS_match, bench->getUniqueName())
|| | 73 (SkCommandLineFlags::ShouldSkip(FLAGS_match, bench->getUniqueName())
|| |
72 !bench->isSuitableFor(Benchmark::kGPU_Backend))) { | 74 !bench->isSuitableFor(Benchmark::kGPU_Backend))) { |
73 bench->unref(); | 75 bench->unref(); |
74 } | 76 } |
| 77 if (FLAGS_cpu) { |
| 78 return new CpuWrappedBenchmark(bench); |
| 79 } |
75 return bench; | 80 return bench; |
76 } | 81 } |
77 | 82 |
78 Benchmark* VisualBenchmarkStream::innerNext() { | 83 Benchmark* VisualBenchmarkStream::innerNext() { |
79 while (fBenches) { | 84 while (fBenches) { |
80 Benchmark* bench = fBenches->factory()(nullptr); | 85 Benchmark* bench = fBenches->factory()(nullptr); |
81 fBenches = fBenches->next(); | 86 fBenches = fBenches->next(); |
82 if (bench->isVisual()) { | 87 if (bench->isVisual()) { |
83 fSourceType = "bench"; | 88 fSourceType = "bench"; |
84 fBenchType = "micro"; | 89 fBenchType = "micro"; |
(...skipping 21 matching lines...) Expand all Loading... |
106 } | 111 } |
107 | 112 |
108 SkString name = SkOSPath::Basename(path.c_str()); | 113 SkString name = SkOSPath::Basename(path.c_str()); |
109 fSourceType = "skp"; | 114 fSourceType = "skp"; |
110 fBenchType = "playback"; | 115 fBenchType = "playback"; |
111 return new VisualSKPBench(name.c_str(), pic.get()); | 116 return new VisualSKPBench(name.c_str(), pic.get()); |
112 } | 117 } |
113 | 118 |
114 return nullptr; | 119 return nullptr; |
115 } | 120 } |
OLD | NEW |