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) | 45 : INHERITED(owner) |
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\t%-*s\tconfig\t
bench\n", |
50 "samples"); | 50 FLAGS_samples, "samples"); |
51 | 51 |
52 // setup json logging if required | 52 // setup json logging if required |
53 if (!FLAGS_outResultsFile.isEmpty()) { | 53 if (!FLAGS_outResultsFile.isEmpty()) { |
54 fResults.reset(new NanoJSONResultsWriter(FLAGS_outResultsFile[0])); | 54 fResults.reset(new NanoJSONResultsWriter(FLAGS_outResultsFile[0])); |
55 } | 55 } |
56 | 56 |
57 if (1 == FLAGS_key.count() % 2) { | 57 if (1 == FLAGS_key.count() % 2) { |
58 SkDebugf("ERROR: --key must be passed with an even number of arguments.\
n"); | 58 SkDebugf("ERROR: --key must be passed with an even number of arguments.\
n"); |
59 } else { | 59 } else { |
60 for (int i = 1; i < FLAGS_key.count(); i += 2) { | 60 for (int i = 1; i < FLAGS_key.count(); i += 2) { |
(...skipping 18 matching lines...) Expand all Loading... |
79 canvas->flush(); | 79 canvas->flush(); |
80 } | 80 } |
81 | 81 |
82 void VisualLightweightBenchModule::printStats(Benchmark* benchmark, int loops) { | 82 void VisualLightweightBenchModule::printStats(Benchmark* benchmark, int loops) { |
83 const SkTArray<double>& measurements = fRecords.back().fMeasurements; | 83 const SkTArray<double>& measurements = fRecords.back().fMeasurements; |
84 const char* shortName = benchmark->getUniqueName(); | 84 const char* shortName = benchmark->getUniqueName(); |
85 | 85 |
86 // update log | 86 // update log |
87 // Note: We currently log only the minimum. It would be interesting to log
more information | 87 // Note: We currently log only the minimum. It would be interesting to log
more information |
88 SkString configName; | 88 SkString configName; |
89 if (FLAGS_msaa > 0) { | 89 if (FLAGS_cpu) { |
90 configName.appendf("msaa_%d", FLAGS_msaa); | 90 configName.append("cpu"); |
| 91 } else if (FLAGS_nvpr) { |
| 92 if (FLAGS_offscreen) { |
| 93 configName.appendf("nvpr_%d", FLAGS_msaa); |
| 94 } else { |
| 95 configName.appendf("nvpr_msaa_%d", FLAGS_msaa); |
| 96 } |
| 97 } else if (FLAGS_msaa > 0) { |
| 98 if (FLAGS_offscreen) { |
| 99 configName.appendf("offscreen_msaa_%d", FLAGS_msaa); |
| 100 } else { |
| 101 configName.appendf("msaa_%d", FLAGS_msaa); |
| 102 } |
91 } else { | 103 } else { |
92 configName.appendf("gpu"); | 104 if (FLAGS_offscreen) { |
| 105 configName.append("offscreen"); |
| 106 } else { |
| 107 configName.append("gpu"); |
| 108 } |
93 } | 109 } |
94 // Log bench name | 110 // Log bench name |
95 fResults->bench(shortName, benchmark->getSize().fX, benchmark->getSize().fY)
; | 111 fResults->bench(shortName, benchmark->getSize().fX, benchmark->getSize().fY)
; |
96 | 112 |
97 fResults->config(configName.c_str()); | 113 fResults->config(configName.c_str()); |
98 fResults->configOption("name", shortName); | 114 fResults->configOption("name", shortName); |
99 SkASSERT(measurements.count()); | 115 SkASSERT(measurements.count()); |
100 Stats stats(measurements); | 116 Stats stats(measurements); |
101 fResults->metric("min_ms", stats.min); | 117 fResults->metric("min_ms", stats.min); |
102 | 118 |
103 // Print output | 119 // Print output |
104 if (FLAGS_verbose) { | 120 if (FLAGS_verbose) { |
105 for (int i = 0; i < measurements.count(); i++) { | 121 for (int i = 0; i < measurements.count(); i++) { |
106 SkDebugf("%s ", HUMANIZE(measurements[i])); | 122 SkDebugf("%s ", HUMANIZE(measurements[i])); |
107 } | 123 } |
108 SkDebugf("%s\n", shortName); | 124 SkDebugf("%s\n", shortName); |
109 } else { | 125 } else { |
110 const double stdDevPercent = 100 * sqrt(stats.var) / stats.mean; | 126 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", | 127 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(), | 128 sk_tools::getCurrResidentSetSizeMB(), |
113 sk_tools::getMaxResidentSetSizeMB(), | 129 sk_tools::getMaxResidentSetSizeMB(), |
114 loops, | 130 loops, |
115 HUMANIZE(stats.min), | 131 HUMANIZE(stats.min), |
116 HUMANIZE(stats.median), | 132 HUMANIZE(stats.median), |
117 HUMANIZE(stats.mean), | 133 HUMANIZE(stats.mean), |
118 HUMANIZE(stats.max), | 134 HUMANIZE(stats.max), |
119 stdDevPercent, | 135 stdDevPercent, |
120 stats.plot.c_str(), | 136 stats.plot.c_str(), |
| 137 configName.c_str(), |
121 shortName); | 138 shortName); |
122 } | 139 } |
123 } | 140 } |
124 | 141 |
125 bool VisualLightweightBenchModule::timingFinished(Benchmark* benchmark, int loop
s, | 142 bool VisualLightweightBenchModule::timingFinished(Benchmark* benchmark, int loop
s, |
126 double measurement) { | 143 double measurement) { |
127 fRecords.back().fMeasurements.push_back(measurement); | 144 fRecords.back().fMeasurements.push_back(measurement); |
128 if (++fCurrentSample > FLAGS_samples) { | 145 if (++fCurrentSample > FLAGS_samples) { |
129 this->printStats(benchmark, loops); | 146 this->printStats(benchmark, loops); |
130 fRecords.push_back(); | 147 fRecords.push_back(); |
131 fCurrentSample = 0; | 148 fCurrentSample = 0; |
132 return true; | 149 return true; |
133 } | 150 } |
134 return false; | 151 return false; |
135 } | 152 } |
136 | 153 |
137 bool VisualLightweightBenchModule::onHandleChar(SkUnichar c) { | 154 bool VisualLightweightBenchModule::onHandleChar(SkUnichar c) { |
138 return true; | 155 return true; |
139 } | 156 } |
OLD | NEW |