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 "CpuWrappedBenchmark.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 if (SkStrEndsWith(FLAGS_skps[i], ".skp")) { | 67 if (SkStrEndsWith(FLAGS_skps[i], ".skp")) { |
68 fSKPs.push_back() = FLAGS_skps[i]; | 68 fSKPs.push_back() = FLAGS_skps[i]; |
69 } else { | 69 } else { |
70 SkOSFile::Iter it(FLAGS_skps[i], ".skp"); | 70 SkOSFile::Iter it(FLAGS_skps[i], ".skp"); |
71 SkString path; | 71 SkString path; |
72 while (it.next(&path)) { | 72 while (it.next(&path)) { |
73 fSKPs.push_back() = SkOSPath::Join(FLAGS_skps[0], path.c_str()); | 73 fSKPs.push_back() = SkOSPath::Join(FLAGS_skps[0], path.c_str()); |
74 } | 74 } |
75 } | 75 } |
76 } | 76 } |
| 77 |
| 78 // seed with an initial benchmark |
| 79 // NOTE the initial benchmark will not have preTimingHooks called, but that
is okay because |
| 80 // it is the warmupbench |
| 81 this->next(); |
77 } | 82 } |
78 | 83 |
79 bool VisualBenchmarkStream::ReadPicture(const char* path, SkAutoTUnref<SkPicture
>* pic) { | 84 bool VisualBenchmarkStream::ReadPicture(const char* path, SkAutoTUnref<SkPicture
>* pic) { |
80 // Not strictly necessary, as it will be checked again later, | 85 // Not strictly necessary, as it will be checked again later, |
81 // but helps to avoid a lot of pointless work if we're going to skip it. | 86 // but helps to avoid a lot of pointless work if we're going to skip it. |
82 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, path)) { | 87 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, path)) { |
83 return false; | 88 return false; |
84 } | 89 } |
85 | 90 |
86 SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(path)); | 91 SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(path)); |
87 if (stream.get() == nullptr) { | 92 if (stream.get() == nullptr) { |
88 SkDebugf("Could not read %s.\n", path); | 93 SkDebugf("Could not read %s.\n", path); |
89 return false; | 94 return false; |
90 } | 95 } |
91 | 96 |
92 pic->reset(SkPicture::CreateFromStream(stream.get())); | 97 pic->reset(SkPicture::CreateFromStream(stream.get())); |
93 if (pic->get() == nullptr) { | 98 if (pic->get() == nullptr) { |
94 SkDebugf("Could not read %s as an SkPicture.\n", path); | 99 SkDebugf("Could not read %s as an SkPicture.\n", path); |
95 return false; | 100 return false; |
96 } | 101 } |
97 return true; | 102 return true; |
98 } | 103 } |
99 | 104 |
100 Benchmark* VisualBenchmarkStream::next() { | 105 Benchmark* VisualBenchmarkStream::next() { |
| 106 Benchmark* bench; |
101 if (!fIsWarmedUp) { | 107 if (!fIsWarmedUp) { |
102 fIsWarmedUp = true; | 108 fIsWarmedUp = true; |
103 return new WarmupBench; | 109 bench = new WarmupBench; |
| 110 } else { |
| 111 // skips non matching benches |
| 112 while ((bench = this->innerNext()) && |
| 113 (SkCommandLineFlags::ShouldSkip(FLAGS_match, bench->getUniqueName
()) || |
| 114 !bench->isSuitableFor(Benchmark::kGPU_Backend))) { |
| 115 bench->unref(); |
| 116 } |
| 117 } |
| 118 if (bench && FLAGS_cpu) { |
| 119 bench = new CpuWrappedBenchmark(bench); |
104 } | 120 } |
105 | 121 |
106 Benchmark* bench; | 122 fBenchmark.reset(bench); |
107 | 123 return fBenchmark; |
108 // skips non matching benches | |
109 while ((bench = this->innerNext()) && | |
110 (SkCommandLineFlags::ShouldSkip(FLAGS_match, bench->getUniqueName())
|| | |
111 !bench->isSuitableFor(Benchmark::kGPU_Backend))) { | |
112 bench->unref(); | |
113 } | |
114 if (FLAGS_cpu) { | |
115 return new CpuWrappedBenchmark(bench); | |
116 } | |
117 return bench; | |
118 } | 124 } |
119 | 125 |
120 Benchmark* VisualBenchmarkStream::innerNext() { | 126 Benchmark* VisualBenchmarkStream::innerNext() { |
121 while (fBenches) { | 127 while (fBenches) { |
122 Benchmark* bench = fBenches->factory()(nullptr); | 128 Benchmark* bench = fBenches->factory()(nullptr); |
123 fBenches = fBenches->next(); | 129 fBenches = fBenches->next(); |
124 if (bench->isVisual()) { | 130 if (bench->isVisual()) { |
125 fSourceType = "bench"; | 131 fSourceType = "bench"; |
126 fBenchType = "micro"; | 132 fBenchType = "micro"; |
127 return bench; | 133 return bench; |
(...skipping 20 matching lines...) Expand all Loading... |
148 } | 154 } |
149 | 155 |
150 SkString name = SkOSPath::Basename(path.c_str()); | 156 SkString name = SkOSPath::Basename(path.c_str()); |
151 fSourceType = "skp"; | 157 fSourceType = "skp"; |
152 fBenchType = "playback"; | 158 fBenchType = "playback"; |
153 return new VisualSKPBench(name.c_str(), pic.get()); | 159 return new VisualSKPBench(name.c_str(), pic.get()); |
154 } | 160 } |
155 | 161 |
156 return nullptr; | 162 return nullptr; |
157 } | 163 } |
OLD | NEW |