Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: tools/VisualBench/VisualBenchmarkStream.cpp

Issue 1392833006: Revert of small tidy of benchmarkstream (Closed) Base URL: https://skia.googlesource.com/skia.git@vb4b
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/VisualBench/VisualBenchmarkStream.h ('k') | tools/VisualBench/VisualStreamTimingModule.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 this->next();
80 } 77 }
81 78
82 bool VisualBenchmarkStream::ReadPicture(const char* path, SkAutoTUnref<SkPicture >* pic) { 79 bool VisualBenchmarkStream::ReadPicture(const char* path, SkAutoTUnref<SkPicture >* pic) {
83 // Not strictly necessary, as it will be checked again later, 80 // Not strictly necessary, as it will be checked again later,
84 // but helps to avoid a lot of pointless work if we're going to skip it. 81 // but helps to avoid a lot of pointless work if we're going to skip it.
85 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, path)) { 82 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, path)) {
86 return false; 83 return false;
87 } 84 }
88 85
89 SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(path)); 86 SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(path));
90 if (stream.get() == nullptr) { 87 if (stream.get() == nullptr) {
91 SkDebugf("Could not read %s.\n", path); 88 SkDebugf("Could not read %s.\n", path);
92 return false; 89 return false;
93 } 90 }
94 91
95 pic->reset(SkPicture::CreateFromStream(stream.get())); 92 pic->reset(SkPicture::CreateFromStream(stream.get()));
96 if (pic->get() == nullptr) { 93 if (pic->get() == nullptr) {
97 SkDebugf("Could not read %s as an SkPicture.\n", path); 94 SkDebugf("Could not read %s as an SkPicture.\n", path);
98 return false; 95 return false;
99 } 96 }
100 return true; 97 return true;
101 } 98 }
102 99
103 Benchmark* VisualBenchmarkStream::next() { 100 Benchmark* VisualBenchmarkStream::next() {
104 Benchmark* bench;
105 if (!fIsWarmedUp) { 101 if (!fIsWarmedUp) {
106 fIsWarmedUp = true; 102 fIsWarmedUp = true;
107 bench = new WarmupBench; 103 return new WarmupBench;
108 } else {
109 // skips non matching benches
110 while ((bench = this->innerNext()) &&
111 (SkCommandLineFlags::ShouldSkip(FLAGS_match, bench->getUniqueName ()) ||
112 !bench->isSuitableFor(Benchmark::kGPU_Backend))) {
113 bench->unref();
114 }
115 }
116 if (bench && FLAGS_cpu) {
117 bench = new CpuWrappedBenchmark(bench);
118 } 104 }
119 105
120 fBenchmark.reset(bench); 106 Benchmark* bench;
121 return fBenchmark; 107
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;
122 } 118 }
123 119
124 Benchmark* VisualBenchmarkStream::innerNext() { 120 Benchmark* VisualBenchmarkStream::innerNext() {
125 while (fBenches) { 121 while (fBenches) {
126 Benchmark* bench = fBenches->factory()(nullptr); 122 Benchmark* bench = fBenches->factory()(nullptr);
127 fBenches = fBenches->next(); 123 fBenches = fBenches->next();
128 if (bench->isVisual()) { 124 if (bench->isVisual()) {
129 fSourceType = "bench"; 125 fSourceType = "bench";
130 fBenchType = "micro"; 126 fBenchType = "micro";
131 return bench; 127 return bench;
(...skipping 20 matching lines...) Expand all
152 } 148 }
153 149
154 SkString name = SkOSPath::Basename(path.c_str()); 150 SkString name = SkOSPath::Basename(path.c_str());
155 fSourceType = "skp"; 151 fSourceType = "skp";
156 fBenchType = "playback"; 152 fBenchType = "playback";
157 return new VisualSKPBench(name.c_str(), pic.get()); 153 return new VisualSKPBench(name.c_str(), pic.get());
158 } 154 }
159 155
160 return nullptr; 156 return nullptr;
161 } 157 }
OLDNEW
« no previous file with comments | « tools/VisualBench/VisualBenchmarkStream.h ('k') | tools/VisualBench/VisualStreamTimingModule.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698