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 #include "VisualLightweightBenchModule.h" | 8 #include "VisualLightweightBenchModule.h" |
9 | 9 |
10 #include "ProcStats.h" | 10 #include "ProcStats.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 return HumanizeMs(ms); | 39 return HumanizeMs(ms); |
40 } | 40 } |
41 | 41 |
42 #define HUMANIZE(time) humanize(time).c_str() | 42 #define HUMANIZE(time) humanize(time).c_str() |
43 | 43 |
44 VisualLightweightBenchModule::VisualLightweightBenchModule(VisualBench* owner) | 44 VisualLightweightBenchModule::VisualLightweightBenchModule(VisualBench* owner) |
45 : INHERITED(owner, true) | 45 : INHERITED(owner, true) |
46 , fCurrentSample(0) | 46 , fCurrentSample(0) |
47 , fResults(new ResultsWriter) { | 47 , fResults(new ResultsWriter) { |
48 // Print header | 48 // Print header |
49 SkDebugf("curr/maxrss\tloops\tmin\tmedian\tmean\tmax\tstddev\t%-*s\tbench\n"
, FLAGS_samples, | 49 SkDebugf("curr/maxrss\tloops\tmin\tmedian\tmean\tmax\tstddev\tconfig\tbench\
n"); |
50 "samples"); | |
51 | 50 |
52 // setup json logging if required | 51 // setup json logging if required |
53 if (!FLAGS_outResultsFile.isEmpty()) { | 52 if (!FLAGS_outResultsFile.isEmpty()) { |
54 fResults.reset(new NanoJSONResultsWriter(FLAGS_outResultsFile[0])); | 53 fResults.reset(new NanoJSONResultsWriter(FLAGS_outResultsFile[0])); |
55 } | 54 } |
56 | 55 |
57 if (1 == FLAGS_key.count() % 2) { | 56 if (1 == FLAGS_key.count() % 2) { |
58 SkDebugf("ERROR: --key must be passed with an even number of arguments.\
n"); | 57 SkDebugf("ERROR: --key must be passed with an even number of arguments.\
n"); |
59 } else { | 58 } else { |
60 for (int i = 1; i < FLAGS_key.count(); i += 2) { | 59 for (int i = 1; i < FLAGS_key.count(); i += 2) { |
(...skipping 17 matching lines...) Expand all Loading... |
78 benchmark->draw(loops, canvas); | 77 benchmark->draw(loops, canvas); |
79 canvas->flush(); | 78 canvas->flush(); |
80 } | 79 } |
81 | 80 |
82 void VisualLightweightBenchModule::printStats(Benchmark* benchmark, int loops) { | 81 void VisualLightweightBenchModule::printStats(Benchmark* benchmark, int loops) { |
83 const SkTArray<double>& measurements = fRecords.back().fMeasurements; | 82 const SkTArray<double>& measurements = fRecords.back().fMeasurements; |
84 const char* shortName = benchmark->getUniqueName(); | 83 const char* shortName = benchmark->getUniqueName(); |
85 | 84 |
86 // update log | 85 // update log |
87 // Note: We currently log only the minimum. It would be interesting to log
more information | 86 // Note: We currently log only the minimum. It would be interesting to log
more information |
88 SkString configName; | |
89 if (FLAGS_msaa > 0) { | |
90 configName.appendf("msaa_%d", FLAGS_msaa); | |
91 } else { | |
92 configName.appendf("gpu"); | |
93 } | |
94 // Log bench name | 87 // Log bench name |
95 fResults->bench(shortName, benchmark->getSize().fX, benchmark->getSize().fY)
; | 88 fResults->bench(shortName, benchmark->getSize().fX, benchmark->getSize().fY)
; |
96 | 89 |
97 fResults->config(configName.c_str()); | 90 fResults->config(this->owner()->currentConfig().humanReadable().c_str()); |
98 fResults->configOption("name", shortName); | 91 fResults->configOption("name", shortName); |
99 SkASSERT(measurements.count()); | 92 SkASSERT(measurements.count()); |
100 Stats stats(measurements); | 93 Stats stats(measurements); |
101 fResults->metric("min_ms", stats.min); | 94 fResults->metric("min_ms", stats.min); |
102 | 95 |
103 // Print output | 96 // Print output |
104 if (FLAGS_verbose) { | 97 if (FLAGS_verbose) { |
105 for (int i = 0; i < measurements.count(); i++) { | 98 for (int i = 0; i < measurements.count(); i++) { |
106 SkDebugf("%s ", HUMANIZE(measurements[i])); | 99 SkDebugf("%s ", HUMANIZE(measurements[i])); |
107 } | 100 } |
108 SkDebugf("%s\n", shortName); | 101 SkDebugf("%s\n", shortName); |
109 } else { | 102 } else { |
110 const double stdDevPercent = 100 * sqrt(stats.var) / stats.mean; | 103 const double stdDevPercent = 100 * sqrt(stats.var) / stats.mean; |
111 SkDebugf("%4d/%-4dMB\t%d\t%s\t%s\t%s\t%s\t%.0f%%\t%s\t%s\n", | 104 SkDebugf("%4d/%-4dMB\t%d\t%s\t%s\t%s\t%s\t%.0f%%\t%s\t%s\t%s\n", |
112 sk_tools::getCurrResidentSetSizeMB(), | 105 sk_tools::getCurrResidentSetSizeMB(), |
113 sk_tools::getMaxResidentSetSizeMB(), | 106 sk_tools::getMaxResidentSetSizeMB(), |
114 loops, | 107 loops, |
115 HUMANIZE(stats.min), | 108 HUMANIZE(stats.min), |
116 HUMANIZE(stats.median), | 109 HUMANIZE(stats.median), |
117 HUMANIZE(stats.mean), | 110 HUMANIZE(stats.mean), |
118 HUMANIZE(stats.max), | 111 HUMANIZE(stats.max), |
119 stdDevPercent, | 112 stdDevPercent, |
120 stats.plot.c_str(), | 113 stats.plot.c_str(), |
| 114 this->owner()->currentConfig().humanReadable().c_str(), |
121 shortName); | 115 shortName); |
122 } | 116 } |
123 } | 117 } |
124 | 118 |
125 bool VisualLightweightBenchModule::timingFinished(Benchmark* benchmark, int loop
s, | 119 bool VisualLightweightBenchModule::timingFinished(Benchmark* benchmark, int loop
s, |
126 double measurement) { | 120 double measurement) { |
127 fRecords.back().fMeasurements.push_back(measurement); | 121 fRecords.back().fMeasurements.push_back(measurement); |
128 if (++fCurrentSample > FLAGS_samples) { | 122 if (++fCurrentSample > FLAGS_samples) { |
129 this->printStats(benchmark, loops); | 123 this->printStats(benchmark, loops); |
130 fRecords.push_back(); | 124 fRecords.push_back(); |
131 fCurrentSample = 0; | 125 fCurrentSample = 0; |
132 return true; | 126 return true; |
133 } | 127 } |
134 return false; | 128 return false; |
135 } | 129 } |
136 | 130 |
137 bool VisualLightweightBenchModule::onHandleChar(SkUnichar c) { | 131 bool VisualLightweightBenchModule::onHandleChar(SkUnichar c) { |
138 return true; | 132 return true; |
139 } | 133 } |
OLD | NEW |