John Reck | 94c40fe | 2014-10-08 09:28:43 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
sergeyv | 7dc370b | 2016-06-17 11:21:11 -0700 | [diff] [blame] | 17 | #include "tests/common/LeakChecker.h" |
Chris Craik | 27e58b4 | 2015-12-07 10:01:38 -0800 | [diff] [blame] | 18 | #include "tests/common/TestScene.h" |
John Reck | 94c40fe | 2014-10-08 09:28:43 -0700 | [diff] [blame] | 19 | |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 20 | #include "Properties.h" |
Seigo Nonaka | b6e2013 | 2016-11-14 14:07:41 +0900 | [diff] [blame] | 21 | #include "hwui/Typeface.h" |
John Reck | e248bd1 | 2015-08-05 13:53:53 -0700 | [diff] [blame] | 22 | |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 23 | #include <benchmark/benchmark.h> |
John Reck | b7dd29e | 2015-10-06 13:28:17 -0700 | [diff] [blame] | 24 | #include <getopt.h> |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 25 | #include <pthread.h> |
John Reck | e702c9c | 2015-10-07 10:26:02 -0700 | [diff] [blame] | 26 | #include <stdio.h> |
John Reck | e702c9c | 2015-10-07 10:26:02 -0700 | [diff] [blame] | 27 | #include <unistd.h> |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 28 | #include <string> |
John Reck | e702c9c | 2015-10-07 10:26:02 -0700 | [diff] [blame] | 29 | #include <unordered_map> |
John Reck | b7dd29e | 2015-10-06 13:28:17 -0700 | [diff] [blame] | 30 | #include <vector> |
John Reck | 7f2e5e3 | 2015-05-05 11:00:53 -0700 | [diff] [blame] | 31 | |
John Reck | 682573c | 2015-10-30 10:37:35 -0700 | [diff] [blame] | 32 | #include <errno.h> |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 33 | #include <fcntl.h> |
| 34 | #include <sys/stat.h> |
| 35 | #include <sys/types.h> |
John Reck | 682573c | 2015-10-30 10:37:35 -0700 | [diff] [blame] | 36 | |
John Reck | 94c40fe | 2014-10-08 09:28:43 -0700 | [diff] [blame] | 37 | using namespace android; |
| 38 | using namespace android::uirenderer; |
Chris Craik | 27e58b4 | 2015-12-07 10:01:38 -0800 | [diff] [blame] | 39 | using namespace android::uirenderer::test; |
John Reck | 94c40fe | 2014-10-08 09:28:43 -0700 | [diff] [blame] | 40 | |
John Reck | b7dd29e | 2015-10-06 13:28:17 -0700 | [diff] [blame] | 41 | static int gRepeatCount = 1; |
Chris Craik | 27e58b4 | 2015-12-07 10:01:38 -0800 | [diff] [blame] | 42 | static std::vector<TestScene::Info> gRunTests; |
John Reck | 682573c | 2015-10-30 10:37:35 -0700 | [diff] [blame] | 43 | static TestScene::Options gOpts; |
John Reck | f148076 | 2016-07-03 18:28:25 -0700 | [diff] [blame] | 44 | std::unique_ptr<benchmark::BenchmarkReporter> gBenchmarkReporter; |
John Reck | b7dd29e | 2015-10-06 13:28:17 -0700 | [diff] [blame] | 45 | |
John Reck | f148076 | 2016-07-03 18:28:25 -0700 | [diff] [blame] | 46 | void run(const TestScene::Info& info, const TestScene::Options& opts, |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 47 | benchmark::BenchmarkReporter* reporter); |
John Reck | 16c9d6a | 2015-11-17 15:51:08 -0800 | [diff] [blame] | 48 | |
John Reck | b7dd29e | 2015-10-06 13:28:17 -0700 | [diff] [blame] | 49 | static void printHelp() { |
John Reck | 682573c | 2015-10-30 10:37:35 -0700 | [diff] [blame] | 50 | printf(R"( |
sergeyv | 202c10b | 2016-07-11 17:53:45 -0700 | [diff] [blame] | 51 | USAGE: hwuimacro [OPTIONS] <TESTNAME> |
John Reck | 682573c | 2015-10-30 10:37:35 -0700 | [diff] [blame] | 52 | |
| 53 | OPTIONS: |
| 54 | -c, --count=NUM NUM loops a test should run (example, number of frames) |
| 55 | -r, --runs=NUM Repeat the test(s) NUM times |
| 56 | -h, --help Display this help |
| 57 | --list List all tests |
| 58 | --wait-for-gpu Set this to wait for the GPU before producing the |
| 59 | next frame. Note that without locked clocks this will |
| 60 | pathologically bad performance due to large idle time |
| 61 | --report-frametime[=weight] If set, the test will print to stdout the |
| 62 | moving average frametime. Weight is optional, default is 10 |
| 63 | --cpuset=name Adds the test to the specified cpuset before running |
| 64 | Not supported on all devices and needs root |
sergeyv | 202c10b | 2016-07-11 17:53:45 -0700 | [diff] [blame] | 65 | --offscreen Render tests off device screen. This option is on by default |
| 66 | --onscreen Render tests on device screen. By default tests |
| 67 | are offscreen rendered |
| 68 | --benchmark_format Set output format. Possible values are tabular, json, csv |
John Reck | 18f442e | 2018-04-09 16:56:34 -0700 | [diff] [blame] | 69 | --renderer=TYPE Sets the render pipeline to use. May be skiagl or skiavk |
John Reck | ec10097 | 2018-04-05 16:41:41 -0700 | [diff] [blame] | 70 | --render-ahead=NUM Sets how far to render-ahead. Must be 0 (default), 1, or 2. |
John Reck | 682573c | 2015-10-30 10:37:35 -0700 | [diff] [blame] | 71 | )"); |
John Reck | b7dd29e | 2015-10-06 13:28:17 -0700 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | static void listTests() { |
| 75 | printf("Tests: \n"); |
Chris Craik | 27e58b4 | 2015-12-07 10:01:38 -0800 | [diff] [blame] | 76 | for (auto&& test : TestScene::testMap()) { |
John Reck | e702c9c | 2015-10-07 10:26:02 -0700 | [diff] [blame] | 77 | auto&& info = test.second; |
| 78 | const char* col1 = info.name.c_str(); |
| 79 | int dlen = info.description.length(); |
| 80 | const char* col2 = info.description.c_str(); |
| 81 | // World's best line breaking algorithm. |
| 82 | do { |
| 83 | int toPrint = dlen; |
| 84 | if (toPrint > 50) { |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 85 | char* found = (char*)memrchr(col2, ' ', 50); |
John Reck | e702c9c | 2015-10-07 10:26:02 -0700 | [diff] [blame] | 86 | if (found) { |
| 87 | toPrint = found - col2; |
| 88 | } else { |
| 89 | toPrint = 50; |
| 90 | } |
| 91 | } |
| 92 | printf("%-20s %.*s\n", col1, toPrint, col2); |
| 93 | col1 = ""; |
| 94 | col2 += toPrint; |
| 95 | dlen -= toPrint; |
| 96 | while (*col2 == ' ') { |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 97 | col2++; |
| 98 | dlen--; |
John Reck | e702c9c | 2015-10-07 10:26:02 -0700 | [diff] [blame] | 99 | } |
| 100 | } while (dlen > 0); |
| 101 | printf("\n"); |
John Reck | b7dd29e | 2015-10-06 13:28:17 -0700 | [diff] [blame] | 102 | } |
| 103 | } |
| 104 | |
John Reck | 682573c | 2015-10-30 10:37:35 -0700 | [diff] [blame] | 105 | static void moveToCpuSet(const char* cpusetName) { |
| 106 | if (access("/dev/cpuset/tasks", F_OK)) { |
| 107 | fprintf(stderr, "don't have access to cpusets, skipping...\n"); |
| 108 | return; |
| 109 | } |
| 110 | static const int BUF_SIZE = 100; |
| 111 | char buffer[BUF_SIZE]; |
| 112 | |
| 113 | if (snprintf(buffer, BUF_SIZE, "/dev/cpuset/%s/tasks", cpusetName) >= BUF_SIZE) { |
| 114 | fprintf(stderr, "Error, cpusetName too large to fit in buffer '%s'\n", cpusetName); |
| 115 | return; |
| 116 | } |
| 117 | int fd = open(buffer, O_WRONLY | O_CLOEXEC); |
| 118 | if (fd == -1) { |
| 119 | fprintf(stderr, "Error opening file %d\n", errno); |
| 120 | return; |
| 121 | } |
| 122 | pid_t pid = getpid(); |
| 123 | |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 124 | int towrite = snprintf(buffer, BUF_SIZE, "%ld", (long)pid); |
John Reck | 682573c | 2015-10-30 10:37:35 -0700 | [diff] [blame] | 125 | if (towrite >= BUF_SIZE) { |
| 126 | fprintf(stderr, "Buffer wasn't large enough?\n"); |
| 127 | } else { |
| 128 | if (write(fd, buffer, towrite) != towrite) { |
| 129 | fprintf(stderr, "Failed to write, errno=%d", errno); |
| 130 | } |
| 131 | } |
| 132 | close(fd); |
| 133 | } |
| 134 | |
John Reck | f148076 | 2016-07-03 18:28:25 -0700 | [diff] [blame] | 135 | static bool setBenchmarkFormat(const char* format) { |
| 136 | if (!strcmp(format, "tabular")) { |
| 137 | gBenchmarkReporter.reset(new benchmark::ConsoleReporter()); |
| 138 | } else if (!strcmp(format, "json")) { |
| 139 | gBenchmarkReporter.reset(new benchmark::JSONReporter()); |
| 140 | } else if (!strcmp(format, "csv")) { |
| 141 | gBenchmarkReporter.reset(new benchmark::CSVReporter()); |
| 142 | } else { |
| 143 | fprintf(stderr, "Unknown format '%s'", format); |
| 144 | return false; |
| 145 | } |
| 146 | return true; |
| 147 | } |
| 148 | |
John Reck | 113ddd9 | 2017-11-09 16:21:21 -0800 | [diff] [blame] | 149 | static bool setRenderer(const char* renderer) { |
John Reck | 18f442e | 2018-04-09 16:56:34 -0700 | [diff] [blame] | 150 | if (!strcmp(renderer, "skiagl")) { |
John Reck | 113ddd9 | 2017-11-09 16:21:21 -0800 | [diff] [blame] | 151 | Properties::overrideRenderPipelineType(RenderPipelineType::SkiaGL); |
| 152 | } else if (!strcmp(renderer, "skiavk")) { |
| 153 | Properties::overrideRenderPipelineType(RenderPipelineType::SkiaVulkan); |
| 154 | } else { |
| 155 | fprintf(stderr, "Unknown format '%s'", renderer); |
| 156 | return false; |
| 157 | } |
| 158 | return true; |
| 159 | } |
| 160 | |
John Reck | 682573c | 2015-10-30 10:37:35 -0700 | [diff] [blame] | 161 | // For options that only exist in long-form. Anything in the |
| 162 | // 0-255 range is reserved for short options (which just use their ASCII value) |
| 163 | namespace LongOpts { |
| 164 | enum { |
| 165 | Reserved = 255, |
| 166 | List, |
| 167 | WaitForGpu, |
| 168 | ReportFrametime, |
| 169 | CpuSet, |
John Reck | f148076 | 2016-07-03 18:28:25 -0700 | [diff] [blame] | 170 | BenchmarkFormat, |
sergeyv | 202c10b | 2016-07-11 17:53:45 -0700 | [diff] [blame] | 171 | Onscreen, |
John Reck | f148076 | 2016-07-03 18:28:25 -0700 | [diff] [blame] | 172 | Offscreen, |
John Reck | 113ddd9 | 2017-11-09 16:21:21 -0800 | [diff] [blame] | 173 | Renderer, |
John Reck | ec10097 | 2018-04-05 16:41:41 -0700 | [diff] [blame] | 174 | RenderAhead, |
John Reck | 682573c | 2015-10-30 10:37:35 -0700 | [diff] [blame] | 175 | }; |
| 176 | } |
| 177 | |
John Reck | b7dd29e | 2015-10-06 13:28:17 -0700 | [diff] [blame] | 178 | static const struct option LONG_OPTIONS[] = { |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 179 | {"frames", required_argument, nullptr, 'f'}, |
| 180 | {"repeat", required_argument, nullptr, 'r'}, |
| 181 | {"help", no_argument, nullptr, 'h'}, |
| 182 | {"list", no_argument, nullptr, LongOpts::List}, |
| 183 | {"wait-for-gpu", no_argument, nullptr, LongOpts::WaitForGpu}, |
| 184 | {"report-frametime", optional_argument, nullptr, LongOpts::ReportFrametime}, |
| 185 | {"cpuset", required_argument, nullptr, LongOpts::CpuSet}, |
| 186 | {"benchmark_format", required_argument, nullptr, LongOpts::BenchmarkFormat}, |
| 187 | {"onscreen", no_argument, nullptr, LongOpts::Onscreen}, |
| 188 | {"offscreen", no_argument, nullptr, LongOpts::Offscreen}, |
John Reck | 113ddd9 | 2017-11-09 16:21:21 -0800 | [diff] [blame] | 189 | {"renderer", required_argument, nullptr, LongOpts::Renderer}, |
John Reck | ec10097 | 2018-04-05 16:41:41 -0700 | [diff] [blame] | 190 | {"render-ahead", required_argument, nullptr, LongOpts::RenderAhead}, |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 191 | {0, 0, 0, 0}}; |
John Reck | b7dd29e | 2015-10-06 13:28:17 -0700 | [diff] [blame] | 192 | |
| 193 | static const char* SHORT_OPTIONS = "c:r:h"; |
| 194 | |
| 195 | void parseOptions(int argc, char* argv[]) { |
| 196 | int c; |
John Reck | b7dd29e | 2015-10-06 13:28:17 -0700 | [diff] [blame] | 197 | bool error = false; |
| 198 | opterr = 0; |
| 199 | |
| 200 | while (true) { |
John Reck | b7dd29e | 2015-10-06 13:28:17 -0700 | [diff] [blame] | 201 | /* getopt_long stores the option index here. */ |
| 202 | int option_index = 0; |
| 203 | |
| 204 | c = getopt_long(argc, argv, SHORT_OPTIONS, LONG_OPTIONS, &option_index); |
| 205 | |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 206 | if (c == -1) break; |
John Reck | b7dd29e | 2015-10-06 13:28:17 -0700 | [diff] [blame] | 207 | |
| 208 | switch (c) { |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 209 | case 0: |
| 210 | // Option set a flag, don't need to do anything |
| 211 | // (although none of the current LONG_OPTIONS do this...) |
| 212 | break; |
John Reck | b7dd29e | 2015-10-06 13:28:17 -0700 | [diff] [blame] | 213 | |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 214 | case LongOpts::List: |
| 215 | listTests(); |
| 216 | exit(EXIT_SUCCESS); |
| 217 | break; |
John Reck | b7dd29e | 2015-10-06 13:28:17 -0700 | [diff] [blame] | 218 | |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 219 | case 'c': |
| 220 | gOpts.count = atoi(optarg); |
| 221 | if (!gOpts.count) { |
| 222 | fprintf(stderr, "Invalid frames argument '%s'\n", optarg); |
John Reck | 682573c | 2015-10-30 10:37:35 -0700 | [diff] [blame] | 223 | error = true; |
| 224 | } |
John Reck | 682573c | 2015-10-30 10:37:35 -0700 | [diff] [blame] | 225 | break; |
John Reck | 682573c | 2015-10-30 10:37:35 -0700 | [diff] [blame] | 226 | |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 227 | case 'r': |
| 228 | gRepeatCount = atoi(optarg); |
| 229 | if (!gRepeatCount) { |
| 230 | fprintf(stderr, "Invalid repeat argument '%s'\n", optarg); |
| 231 | error = true; |
| 232 | } else { |
| 233 | gRepeatCount = (gRepeatCount > 0 ? gRepeatCount : INT_MAX); |
| 234 | } |
John Reck | f148076 | 2016-07-03 18:28:25 -0700 | [diff] [blame] | 235 | break; |
John Reck | f148076 | 2016-07-03 18:28:25 -0700 | [diff] [blame] | 236 | |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 237 | case LongOpts::ReportFrametime: |
| 238 | if (optarg) { |
| 239 | gOpts.reportFrametimeWeight = atoi(optarg); |
| 240 | if (!gOpts.reportFrametimeWeight) { |
| 241 | fprintf(stderr, "Invalid report frametime weight '%s'\n", optarg); |
| 242 | error = true; |
| 243 | } |
| 244 | } else { |
| 245 | gOpts.reportFrametimeWeight = 10; |
| 246 | } |
| 247 | break; |
sergeyv | 202c10b | 2016-07-11 17:53:45 -0700 | [diff] [blame] | 248 | |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 249 | case LongOpts::WaitForGpu: |
| 250 | Properties::waitForGpuCompletion = true; |
| 251 | break; |
John Reck | f148076 | 2016-07-03 18:28:25 -0700 | [diff] [blame] | 252 | |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 253 | case LongOpts::CpuSet: |
| 254 | if (!optarg) { |
| 255 | error = true; |
| 256 | break; |
| 257 | } |
| 258 | moveToCpuSet(optarg); |
| 259 | break; |
John Reck | b7dd29e | 2015-10-06 13:28:17 -0700 | [diff] [blame] | 260 | |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 261 | case LongOpts::BenchmarkFormat: |
| 262 | if (!optarg) { |
| 263 | error = true; |
| 264 | break; |
| 265 | } |
| 266 | if (!setBenchmarkFormat(optarg)) { |
| 267 | error = true; |
| 268 | } |
| 269 | break; |
| 270 | |
John Reck | 113ddd9 | 2017-11-09 16:21:21 -0800 | [diff] [blame] | 271 | case LongOpts::Renderer: |
| 272 | if (!optarg) { |
| 273 | error = true; |
| 274 | break; |
| 275 | } |
| 276 | if (!setRenderer(optarg)) { |
| 277 | error = true; |
| 278 | } |
| 279 | break; |
| 280 | |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 281 | case LongOpts::Onscreen: |
| 282 | gOpts.renderOffscreen = false; |
| 283 | break; |
| 284 | |
| 285 | case LongOpts::Offscreen: |
| 286 | gOpts.renderOffscreen = true; |
| 287 | break; |
| 288 | |
John Reck | ec10097 | 2018-04-05 16:41:41 -0700 | [diff] [blame] | 289 | case LongOpts::RenderAhead: |
| 290 | if (!optarg) { |
| 291 | error = true; |
| 292 | } |
| 293 | gOpts.renderAhead = atoi(optarg); |
| 294 | if (gOpts.renderAhead < 0 || gOpts.renderAhead > 2) { |
| 295 | error = true; |
| 296 | } |
| 297 | break; |
| 298 | |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 299 | case 'h': |
| 300 | printHelp(); |
| 301 | exit(EXIT_SUCCESS); |
| 302 | break; |
| 303 | |
| 304 | case '?': |
| 305 | fprintf(stderr, "Unrecognized option '%s'\n", argv[optind - 1]); |
John Reck | b7dd29e | 2015-10-06 13:28:17 -0700 | [diff] [blame] | 306 | // fall-through |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 307 | default: |
| 308 | error = true; |
| 309 | break; |
John Reck | b7dd29e | 2015-10-06 13:28:17 -0700 | [diff] [blame] | 310 | } |
| 311 | } |
| 312 | |
| 313 | if (error) { |
| 314 | fprintf(stderr, "Try 'hwuitest --help' for more information.\n"); |
| 315 | exit(EXIT_FAILURE); |
| 316 | } |
| 317 | |
| 318 | /* Print any remaining command line arguments (not options). */ |
| 319 | if (optind < argc) { |
| 320 | do { |
| 321 | const char* test = argv[optind++]; |
sergeyv | 202c10b | 2016-07-11 17:53:45 -0700 | [diff] [blame] | 322 | auto pos = TestScene::testMap().find(test); |
| 323 | if (pos == TestScene::testMap().end()) { |
| 324 | fprintf(stderr, "Unknown test '%s'\n", test); |
| 325 | exit(EXIT_FAILURE); |
John Reck | b7dd29e | 2015-10-06 13:28:17 -0700 | [diff] [blame] | 326 | } else { |
sergeyv | 202c10b | 2016-07-11 17:53:45 -0700 | [diff] [blame] | 327 | gRunTests.push_back(pos->second); |
John Reck | b7dd29e | 2015-10-06 13:28:17 -0700 | [diff] [blame] | 328 | } |
| 329 | } while (optind < argc); |
| 330 | } else { |
sergeyv | 202c10b | 2016-07-11 17:53:45 -0700 | [diff] [blame] | 331 | for (auto& iter : TestScene::testMap()) { |
| 332 | gRunTests.push_back(iter.second); |
| 333 | } |
John Reck | b7dd29e | 2015-10-06 13:28:17 -0700 | [diff] [blame] | 334 | } |
| 335 | } |
| 336 | |
Chris Craik | 0318887 | 2015-02-02 18:39:33 -0800 | [diff] [blame] | 337 | int main(int argc, char* argv[]) { |
John Reck | 682573c | 2015-10-30 10:37:35 -0700 | [diff] [blame] | 338 | // set defaults |
| 339 | gOpts.count = 150; |
| 340 | |
Seigo Nonaka | b6e2013 | 2016-11-14 14:07:41 +0900 | [diff] [blame] | 341 | Typeface::setRobotoTypefaceForTest(); |
| 342 | |
John Reck | b7dd29e | 2015-10-06 13:28:17 -0700 | [diff] [blame] | 343 | parseOptions(argc, argv); |
John Reck | f148076 | 2016-07-03 18:28:25 -0700 | [diff] [blame] | 344 | if (!gBenchmarkReporter && gOpts.renderOffscreen) { |
| 345 | gBenchmarkReporter.reset(new benchmark::ConsoleReporter()); |
| 346 | } |
| 347 | |
| 348 | if (gBenchmarkReporter) { |
| 349 | size_t name_field_width = 10; |
| 350 | for (auto&& test : gRunTests) { |
| 351 | name_field_width = std::max<size_t>(name_field_width, test.name.size()); |
| 352 | } |
| 353 | // _50th, _90th, etc... |
| 354 | name_field_width += 5; |
| 355 | |
| 356 | benchmark::BenchmarkReporter::Context context; |
John Reck | f148076 | 2016-07-03 18:28:25 -0700 | [diff] [blame] | 357 | context.name_field_width = name_field_width; |
| 358 | gBenchmarkReporter->ReportContext(context); |
| 359 | } |
John Reck | b7dd29e | 2015-10-06 13:28:17 -0700 | [diff] [blame] | 360 | |
| 361 | for (int i = 0; i < gRepeatCount; i++) { |
| 362 | for (auto&& test : gRunTests) { |
John Reck | f148076 | 2016-07-03 18:28:25 -0700 | [diff] [blame] | 363 | run(test, gOpts, gBenchmarkReporter.get()); |
Tim Murray | 1a0f1c7 | 2015-05-06 11:37:37 -0700 | [diff] [blame] | 364 | } |
| 365 | } |
John Reck | f148076 | 2016-07-03 18:28:25 -0700 | [diff] [blame] | 366 | |
| 367 | if (gBenchmarkReporter) { |
| 368 | gBenchmarkReporter->Finalize(); |
| 369 | } |
| 370 | |
sergeyv | 7dc370b | 2016-06-17 11:21:11 -0700 | [diff] [blame] | 371 | LeakChecker::checkForLeaks(); |
John Reck | 94c40fe | 2014-10-08 09:28:43 -0700 | [diff] [blame] | 372 | return 0; |
| 373 | } |