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

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

Issue 2018603003: Remove VisualBench and its Android implementation. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 6 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/VisualLightweightBenchModule.h ('k') | tools/VisualBench/VisualModule.h » ('j') | 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 2015 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 "VisualLightweightBenchModule.h"
9
10 #include "ProcStats.h"
11 #include "SkApplication.h"
12 #include "SkCanvas.h"
13 #include "SkCommandLineFlags.h"
14 #include "SkGraphics.h"
15 #include "SkGr.h"
16 #include "SkOSFile.h"
17 #include "SkStream.h"
18 #include "Stats.h"
19 #include "gl/GrGLInterface.h"
20
21 // Between samples we reset context
22 // Between frames we swap buffers
23 DEFINE_bool2(verbose, v, false, "enable verbose output from the test driver.");
24 DEFINE_string(outResultsFile, "", "If given, write results here as JSON.");
25 DEFINE_string(key, "",
26 "Space-separated key/value pairs to add to JSON identifying this b uilder.");
27 DEFINE_string(properties, "",
28 "Space-separated key/value pairs to add to JSON identifying this r un.");
29 DEFINE_int32(samples, 10, "Number of times to time each skp.");
30
31 static SkString humanize(double ms) {
32 if (FLAGS_verbose) {
33 return SkStringPrintf("%llu", (uint64_t)(ms*1e6));
34 }
35 return HumanizeMs(ms);
36 }
37
38 #define HUMANIZE(time) humanize(time).c_str()
39
40 VisualLightweightBenchModule::VisualLightweightBenchModule(VisualBench* owner)
41 : INHERITED(owner)
42 , fCurrentSample(0)
43 , fResults(new ResultsWriter) {
44 // Print header
45 SkDebugf("curr/maxrss\tloops\tmin\tmedian\tmean\tmax\tstddev\t%-*s\tconfig\t bench\n",
46 FLAGS_samples, "samples");
47
48 // setup json logging if required
49 if (!FLAGS_outResultsFile.isEmpty()) {
50 fResults.reset(new NanoJSONResultsWriter(FLAGS_outResultsFile[0]));
51 }
52
53 if (1 == FLAGS_key.count() % 2) {
54 SkDebugf("ERROR: --key must be passed with an even number of arguments.\ n");
55 } else {
56 for (int i = 1; i < FLAGS_key.count(); i += 2) {
57 fResults->key(FLAGS_key[i - 1], FLAGS_key[i]);
58 }
59 }
60
61 if (1 == FLAGS_properties.count() % 2) {
62 SkDebugf("ERROR: --properties must be passed with an even number of argu ments.\n");
63 } else {
64 for (int i = 1; i < FLAGS_properties.count(); i += 2) {
65 fResults->property(FLAGS_properties[i - 1], FLAGS_properties[i]);
66 }
67 }
68
69 // seed an initial record
70 fRecords.push_back();
71 }
72
73 void VisualLightweightBenchModule::renderFrame(SkCanvas* canvas, Benchmark* benc hmark, int loops) {
74 benchmark->draw(loops, canvas);
75 canvas->flush();
76 }
77
78 void VisualLightweightBenchModule::printStats(Benchmark* benchmark, int loops) {
79 const SkTArray<double>& measurements = fRecords.back().fMeasurements;
80 const char* shortName = benchmark->getUniqueName();
81
82 // update log
83 // Note: We currently log only the minimum. It would be interesting to log more information
84 SkString configName;
85 if (FLAGS_cpu) {
86 configName.append("cpu");
87 } else if (FLAGS_nvpr) {
88 if (FLAGS_offscreen) {
89 configName.appendf("nvpr_%d", FLAGS_msaa);
90 } else {
91 configName.appendf("nvpr_msaa_%d", FLAGS_msaa);
92 }
93 } else if (FLAGS_msaa > 0) {
94 if (FLAGS_offscreen) {
95 configName.appendf("offscreen_msaa_%d", FLAGS_msaa);
96 } else {
97 configName.appendf("msaa_%d", FLAGS_msaa);
98 }
99 } else {
100 if (FLAGS_offscreen) {
101 configName.append("offscreen");
102 } else {
103 configName.append("gpu");
104 }
105 }
106 // Log bench name
107 fResults->bench(shortName, benchmark->getSize().fX, benchmark->getSize().fY) ;
108
109 fResults->config(configName.c_str());
110 fResults->configOption("name", shortName);
111 SkASSERT(measurements.count());
112 Stats stats(measurements);
113 fResults->metric("min_ms", stats.min);
114
115 // Print output
116 if (FLAGS_verbose) {
117 for (int i = 0; i < measurements.count(); i++) {
118 SkDebugf("%s ", HUMANIZE(measurements[i]));
119 }
120 SkDebugf("%s\n", shortName);
121 } else {
122 const double stdDevPercent = 100 * sqrt(stats.var) / stats.mean;
123 SkDebugf("%4d/%-4dMB\t%d\t%s\t%s\t%s\t%s\t%.0f%%\t%s\t%s\t%s\n",
124 sk_tools::getCurrResidentSetSizeMB(),
125 sk_tools::getMaxResidentSetSizeMB(),
126 loops,
127 HUMANIZE(stats.min),
128 HUMANIZE(stats.median),
129 HUMANIZE(stats.mean),
130 HUMANIZE(stats.max),
131 stdDevPercent,
132 stats.plot.c_str(),
133 configName.c_str(),
134 shortName);
135 }
136 }
137
138 bool VisualLightweightBenchModule::timingFinished(Benchmark* benchmark, int loop s,
139 double measurement) {
140 fRecords.back().fMeasurements.push_back(measurement);
141 if (++fCurrentSample > FLAGS_samples) {
142 this->printStats(benchmark, loops);
143 fRecords.push_back();
144 fCurrentSample = 0;
145 return true;
146 }
147 return false;
148 }
149
150 bool VisualLightweightBenchModule::onHandleChar(SkUnichar c) {
151 return true;
152 }
OLDNEW
« no previous file with comments | « tools/VisualBench/VisualLightweightBenchModule.h ('k') | tools/VisualBench/VisualModule.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698