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

Side by Side Diff: bench/nanobench.cpp

Issue 1671573002: Create a thermal manager class and wire it in to nanobench behind a flag (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tweaks Created 4 years, 10 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 | « no previous file | gyp/bench.gyp » ('j') | tools/ThermalManager.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 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 <ctype.h> 8 #include <ctype.h>
9 9
10 #include "nanobench.h" 10 #include "nanobench.h"
(...skipping 20 matching lines...) Expand all
31 #include "SkData.h" 31 #include "SkData.h"
32 #include "SkForceLinking.h" 32 #include "SkForceLinking.h"
33 #include "SkGraphics.h" 33 #include "SkGraphics.h"
34 #include "SkOSFile.h" 34 #include "SkOSFile.h"
35 #include "SkPictureRecorder.h" 35 #include "SkPictureRecorder.h"
36 #include "SkPictureUtils.h" 36 #include "SkPictureUtils.h"
37 #include "SkString.h" 37 #include "SkString.h"
38 #include "SkSurface.h" 38 #include "SkSurface.h"
39 #include "SkTaskGroup.h" 39 #include "SkTaskGroup.h"
40 #include "SkThreadUtils.h" 40 #include "SkThreadUtils.h"
41 #include "ThermalManager.h"
41 42
42 #include <stdlib.h> 43 #include <stdlib.h>
43 44
44 #ifndef SK_BUILD_FOR_WIN32 45 #ifndef SK_BUILD_FOR_WIN32
45 #include <unistd.h> 46 #include <unistd.h>
46 #endif 47 #endif
47 48
48 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK 49 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
49 #include "nanobenchAndroid.h" 50 #include "nanobenchAndroid.h"
50 #endif 51 #endif
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 DEFINE_string(zoom, "1.0,0", "Comma-separated zoomMax,zoomPeriodMs factors for a periodic SKP zoom " 105 DEFINE_string(zoom, "1.0,0", "Comma-separated zoomMax,zoomPeriodMs factors for a periodic SKP zoom "
105 "function that ping-pongs between 1.0 and zoomMax." ); 106 "function that ping-pongs between 1.0 and zoomMax." );
106 DEFINE_bool(bbh, true, "Build a BBH for SKPs?"); 107 DEFINE_bool(bbh, true, "Build a BBH for SKPs?");
107 DEFINE_bool(mpd, true, "Use MultiPictureDraw for the SKPs?"); 108 DEFINE_bool(mpd, true, "Use MultiPictureDraw for the SKPs?");
108 DEFINE_bool(loopSKP, true, "Loop SKPs like we do for micro benches?"); 109 DEFINE_bool(loopSKP, true, "Loop SKPs like we do for micro benches?");
109 DEFINE_int32(flushEvery, 10, "Flush --outResultsFile every Nth run."); 110 DEFINE_int32(flushEvery, 10, "Flush --outResultsFile every Nth run.");
110 DEFINE_bool(resetGpuContext, true, "Reset the GrContext before running each test ."); 111 DEFINE_bool(resetGpuContext, true, "Reset the GrContext before running each test .");
111 DEFINE_bool(gpuStats, false, "Print GPU stats after each gpu benchmark?"); 112 DEFINE_bool(gpuStats, false, "Print GPU stats after each gpu benchmark?");
112 DEFINE_bool(gpuStatsDump, false, "Dump GPU states after each benchmark to json") ; 113 DEFINE_bool(gpuStatsDump, false, "Dump GPU states after each benchmark to json") ;
113 DEFINE_bool(keepAlive, false, "Print a message every so often so that we don't t ime out"); 114 DEFINE_bool(keepAlive, false, "Print a message every so often so that we don't t ime out");
115 DEFINE_string(useThermalManager, "0,1,10,1000", "enabled,threshold,sleepTimeMs,T imeoutMs for "
116 "thermalManager\n");
114 117
115 DEFINE_string(sourceType, "", 118 DEFINE_string(sourceType, "",
116 "Apply usual --match rules to source type: bench, gm, skp, image, etc.") ; 119 "Apply usual --match rules to source type: bench, gm, skp, image, etc.") ;
117 DEFINE_string(benchType, "", 120 DEFINE_string(benchType, "",
118 "Apply usual --match rules to bench type: micro, recording, playback, sk codec, etc."); 121 "Apply usual --match rules to bench type: micro, recording, playback, sk codec, etc.");
119 122
120 static double now_ms() { return SkTime::GetNSecs() * 1e-6; } 123 static double now_ms() { return SkTime::GetNSecs() * 1e-6; }
121 124
122 static SkString humanize(double ms) { 125 static SkString humanize(double ms) {
123 if (FLAGS_verbose) return SkStringPrintf("%llu", (uint64_t)(ms*1e6)); 126 if (FLAGS_verbose) return SkStringPrintf("%llu", (uint64_t)(ms*1e6));
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 } else if (FLAGS_ms) { 1052 } else if (FLAGS_ms) {
1050 SkDebugf("curr/maxrss\tloops\tmin\tmedian\tmean\tmax\tstddev\tsamples\tc onfig\tbench\n"); 1053 SkDebugf("curr/maxrss\tloops\tmin\tmedian\tmean\tmax\tstddev\tsamples\tc onfig\tbench\n");
1051 } else { 1054 } else {
1052 SkDebugf("curr/maxrss\tloops\tmin\tmedian\tmean\tmax\tstddev\t%-*s\tconf ig\tbench\n", 1055 SkDebugf("curr/maxrss\tloops\tmin\tmedian\tmean\tmax\tstddev\t%-*s\tconf ig\tbench\n",
1053 FLAGS_samples, "samples"); 1056 FLAGS_samples, "samples");
1054 } 1057 }
1055 1058
1056 SkTArray<Config> configs; 1059 SkTArray<Config> configs;
1057 create_configs(&configs); 1060 create_configs(&configs);
1058 1061
1062 #ifdef THERMAL_MANAGER_SUPPORTED
1063 int tmEnabled, tmThreshold, tmSleepTimeMs, tmTimeoutMs;
1064 if (4 != sscanf(FLAGS_useThermalManager[0], "%d,%d,%d,%d",
1065 &tmEnabled, &tmThreshold, &tmSleepTimeMs, &tmTimeoutMs)) {
1066 SkDebugf("Can't parse %s from --useThermalManager.\n", FLAGS_useThermalM anager[0]);
1067 exit(1);
1068 }
1069 ThermalManager tm(tmThreshold, tmSleepTimeMs, tmTimeoutMs);
1070 #endif
1071
1059 if (FLAGS_keepAlive) { 1072 if (FLAGS_keepAlive) {
1060 start_keepalive(); 1073 start_keepalive();
1061 } 1074 }
1062 1075
1063 int runs = 0; 1076 int runs = 0;
1064 BenchmarkStream benchStream; 1077 BenchmarkStream benchStream;
1065 while (Benchmark* b = benchStream.next()) { 1078 while (Benchmark* b = benchStream.next()) {
1066 SkAutoTDelete<Benchmark> bench(b); 1079 SkAutoTDelete<Benchmark> bench(b);
1067 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, bench->getUniqueName())) { 1080 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, bench->getUniqueName())) {
1068 continue; 1081 continue;
1069 } 1082 }
1070 1083
1071 if (!configs.empty()) { 1084 if (!configs.empty()) {
1072 log->bench(bench->getUniqueName(), bench->getSize().fX, bench->getSi ze().fY); 1085 log->bench(bench->getUniqueName(), bench->getSize().fX, bench->getSi ze().fY);
1073 bench->delayedSetup(); 1086 bench->delayedSetup();
1074 } 1087 }
1075 for (int i = 0; i < configs.count(); ++i) { 1088 for (int i = 0; i < configs.count(); ++i) {
1089 #ifdef THERMAL_MANAGER_SUPPORTED
1090 if (tmEnabled && !tm.coolOffIfNecessary()) {
1091 SkDebugf("Could not cool off, timings will be throttled\n");
1092 }
1093 #endif
1076 Target* target = is_enabled(b, configs[i]); 1094 Target* target = is_enabled(b, configs[i]);
1077 if (!target) { 1095 if (!target) {
1078 continue; 1096 continue;
1079 } 1097 }
1080 1098
1081 // During HWUI output this canvas may be nullptr. 1099 // During HWUI output this canvas may be nullptr.
1082 SkCanvas* canvas = target->getCanvas(); 1100 SkCanvas* canvas = target->getCanvas();
1083 const char* config = target->config.name.c_str(); 1101 const char* config = target->config.name.c_str();
1084 1102
1085 if (FLAGS_pre_log) { 1103 if (FLAGS_pre_log) {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1222 1240
1223 return 0; 1241 return 0;
1224 } 1242 }
1225 1243
1226 #if !defined SK_BUILD_FOR_IOS 1244 #if !defined SK_BUILD_FOR_IOS
1227 int main(int argc, char** argv) { 1245 int main(int argc, char** argv) {
1228 SkCommandLineFlags::Parse(argc, argv); 1246 SkCommandLineFlags::Parse(argc, argv);
1229 return nanobench_main(); 1247 return nanobench_main();
1230 } 1248 }
1231 #endif 1249 #endif
OLDNEW
« no previous file with comments | « no previous file | gyp/bench.gyp » ('j') | tools/ThermalManager.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698