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

Side by Side Diff: tools/kilobench/kilobench.cpp

Issue 1582903002: Add skeleton for kilobench experiments (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove kilobench if no gpu support Created 4 years, 11 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 | « gyp/most.gyp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "Benchmark.h"
mtklein 2016/01/14 15:59:10 If you're only going to bench .skps, you may find
9 #include "SkCommandLineFlags.h"
10 #include "SkOSFile.h"
11 #include "SkStream.h"
12 #include "VisualSKPBench.h"
13
14 // To get image decoders linked in we have to do the below magic
15 #include "SkForceLinking.h"
16 #include "SkImageDecoder.h"
17 __SK_FORCE_IMAGE_DECODER_LINKING;
18
19 DEFINE_string(skps, "skps", "Directory to read skps from.");
20
21 DEFINE_string2(match, m, nullptr,
22 "[~][^]substring[$] [...] of GM name to run.\n"
23 "Multiple matches may be separated by spaces.\n"
24 "~ causes a matching bench to always be skipped\n"
25 "^ requires the start of the bench to match\n"
26 "$ requires the end of the bench to match\n"
27 "^ and $ requires an exact match\n"
28 "If a bench does not match any list entry,\n"
29 "it is skipped unless some list entry starts with ~");
30
31 namespace kilobench {
32 class BenchmarkStream {
33 public:
34 BenchmarkStream() : fCurrentSKP(0) {
mtklein 2016/01/14 15:59:11 This proved to be a miserable pattern to maintain
35 for (int i = 0; i < FLAGS_skps.count(); i++) {
36 if (SkStrEndsWith(FLAGS_skps[i], ".skp")) {
37 fSKPs.push_back() = FLAGS_skps[i];
38 } else {
39 SkOSFile::Iter it(FLAGS_skps[i], ".skp");
40 SkString path;
41 while (it.next(&path)) {
42 fSKPs.push_back() = SkOSPath::Join(FLAGS_skps[0], path.c_str ());
43 }
44 }
45 }
46 }
47
48 Benchmark* next() {
49 Benchmark* bench = nullptr;
50 // skips non matching benches
51 while ((bench = this->innerNext()) &&
52 (SkCommandLineFlags::ShouldSkip(FLAGS_match, bench->getUniqueName ()) ||
53 !bench->isSuitableFor(Benchmark::kGPU_Backend))) {
mtklein 2016/01/14 15:59:11 are there .skps which are not suitable for GPU ben
54 bench->unref();
55 }
56 return bench;
57 }
58
59 private:
60 static bool ReadPicture(const char* path, SkAutoTUnref<SkPicture>* pic) {
61 // Not strictly necessary, as it will be checked again later,
62 // but helps to avoid a lot of pointless work if we're going to skip it.
63 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, path)) {
mtklein 2016/01/14 15:59:10 If you're sticking to .skps, this is probably the
64 return false;
65 }
66
67 SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(path));
68 if (stream.get() == nullptr) {
69 SkDebugf("Could not read %s.\n", path);
70 return false;
71 }
72
73 pic->reset(SkPicture::CreateFromStream(stream.get()));
74 if (pic->get() == nullptr) {
75 SkDebugf("Could not read %s as an SkPicture.\n", path);
76 return false;
77 }
78 return true;
79 }
80
81 Benchmark* innerNext() {
82 // Render skps
83 while (fCurrentSKP < fSKPs.count()) {
84 const SkString& path = fSKPs[fCurrentSKP++];
85 SkAutoTUnref<SkPicture> pic;
86 if (!ReadPicture(path.c_str(), &pic)) {
87 continue;
88 }
89
90 SkString name = SkOSPath::Basename(path.c_str());
91 return new VisualSKPBench(name.c_str(), pic.get());
92 }
93
94 return nullptr;
95 }
96
97 SkTArray<SkString> fSKPs;
98 int fCurrentSKP;
99 };
100
101 };
mtklein 2016/01/14 15:59:11 namespaces don't need ; at the end, but it is nice
102 /*
103 * This is an experimental GPU only benchmarking program for skps
mtklein 2016/01/14 15:59:11 Up top?
104 */
105 int kilobench_main() {
106 kilobench::BenchmarkStream benchStream;
107 while (Benchmark* bench = benchStream.next()) {
mtklein 2016/01/14 15:59:10 probably nice to delete these at some point
108 }
mtklein 2016/01/14 15:59:10 aww man, https://www.youtube.com/watch?v=_O1hM-k3a
109 return 0;
110 }
111
112 #if !defined SK_BUILD_FOR_IOS
113 int main(int argc, char** argv) {
114 SkCommandLineFlags::Parse(argc, argv);
115 return kilobench_main();
116 }
117 #endif
OLDNEW
« no previous file with comments | « gyp/most.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698