mtklein | f372321 | 2014-06-25 14:08:00 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 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 | |
mtklein | bb6a028 | 2014-07-01 08:43:42 -0700 | [diff] [blame] | 8 | #include <ctype.h> |
| 9 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 10 | #include "bench/nanobench.h" |
tomhudson | d968a6f | 2015-03-26 11:28:06 -0700 | [diff] [blame] | 11 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 12 | #include "bench/AndroidCodecBench.h" |
| 13 | #include "bench/Benchmark.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 14 | #include "bench/CodecBench.h" |
| 15 | #include "bench/CodecBenchPriv.h" |
| 16 | #include "bench/GMBench.h" |
Brian Salomon | 31fddc3 | 2021-04-30 13:08:55 -0400 | [diff] [blame] | 17 | #include "bench/MSKPBench.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 18 | #include "bench/RecordingBench.h" |
| 19 | #include "bench/ResultsWriter.h" |
| 20 | #include "bench/SKPAnimationBench.h" |
| 21 | #include "bench/SKPBench.h" |
Hal Canary | 5dfefa2 | 2019-10-24 13:52:17 -0400 | [diff] [blame] | 22 | #include "bench/SkGlyphCacheBench.h" |
Brian Osman | 68870aa | 2020-07-08 14:12:43 -0400 | [diff] [blame] | 23 | #include "bench/SkSLBench.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 24 | #include "include/codec/SkAndroidCodec.h" |
| 25 | #include "include/codec/SkCodec.h" |
| 26 | #include "include/core/SkCanvas.h" |
| 27 | #include "include/core/SkData.h" |
| 28 | #include "include/core/SkGraphics.h" |
| 29 | #include "include/core/SkPictureRecorder.h" |
| 30 | #include "include/core/SkString.h" |
| 31 | #include "include/core/SkSurface.h" |
Ben Wagner | acf98df | 2019-07-12 12:51:44 -0400 | [diff] [blame] | 32 | #include "include/core/SkTime.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 33 | #include "src/core/SkAutoMalloc.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 34 | #include "src/core/SkColorSpacePriv.h" |
Ben Wagner | ab6eefe | 2019-05-20 11:02:49 -0400 | [diff] [blame] | 35 | #include "src/core/SkLeanWindows.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 36 | #include "src/core/SkOSFile.h" |
| 37 | #include "src/core/SkTaskGroup.h" |
| 38 | #include "src/core/SkTraceEvent.h" |
John Stiles | 2ef627a | 2021-03-23 10:25:02 -0400 | [diff] [blame] | 39 | #include "src/gpu/GrShaderUtils.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 40 | #include "src/utils/SkJSONWriter.h" |
| 41 | #include "src/utils/SkOSPath.h" |
Jim Van Verth | 8a9a371 | 2019-05-31 10:49:12 -0400 | [diff] [blame] | 42 | #include "tools/AutoreleasePool.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 43 | #include "tools/CrashHandler.h" |
Brian Salomon | 31fddc3 | 2021-04-30 13:08:55 -0400 | [diff] [blame] | 44 | #include "tools/MSKPPlayer.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 45 | #include "tools/ProcStats.h" |
| 46 | #include "tools/Stats.h" |
| 47 | #include "tools/flags/CommonFlags.h" |
| 48 | #include "tools/flags/CommonFlagsConfig.h" |
| 49 | #include "tools/ios_utils.h" |
| 50 | #include "tools/trace/EventTracingPriv.h" |
| 51 | #include "tools/trace/SkDebugfTracer.h" |
mtklein | f372321 | 2014-06-25 14:08:00 -0700 | [diff] [blame] | 52 | |
Hal Canary | 0f66681 | 2018-03-22 15:21:12 -0400 | [diff] [blame] | 53 | #ifdef SK_XML |
Florin Malita | b341810 | 2020-10-15 18:10:29 -0400 | [diff] [blame] | 54 | #include "modules/svg/include/SkSVGDOM.h" |
Hal Canary | 0f66681 | 2018-03-22 15:21:12 -0400 | [diff] [blame] | 55 | #endif // SK_XML |
| 56 | |
Leon Scroggins III | 87caae6 | 2020-05-04 10:02:45 -0400 | [diff] [blame] | 57 | #ifdef SK_ENABLE_ANDROID_UTILS |
| 58 | #include "bench/BitmapRegionDecoderBench.h" |
| 59 | #include "client_utils/android/BitmapRegionDecoder.h" |
| 60 | #endif |
| 61 | |
Adlai Holler | 684838f | 2020-05-12 10:41:04 -0400 | [diff] [blame] | 62 | #include <cinttypes> |
bungeman | 60e0fee | 2015-08-26 05:15:46 -0700 | [diff] [blame] | 63 | #include <stdlib.h> |
John Stiles | fbd050b | 2020-08-03 13:21:46 -0400 | [diff] [blame] | 64 | #include <memory> |
Mike Klein | 03141d2 | 2017-10-30 11:57:15 -0400 | [diff] [blame] | 65 | #include <thread> |
bungeman | 60e0fee | 2015-08-26 05:15:46 -0700 | [diff] [blame] | 66 | |
Mike Reed | c928fe2 | 2017-06-05 10:20:31 -0400 | [diff] [blame] | 67 | extern bool gSkForceRasterPipelineBlitter; |
Mike Reed | 0e2fb66 | 2021-07-23 11:00:40 -0400 | [diff] [blame] | 68 | extern bool gForceHighPrecisionRasterPipeline; |
Mike Klein | 2a57e79 | 2020-01-14 12:47:52 -0600 | [diff] [blame] | 69 | extern bool gUseSkVMBlitter; |
Mike Klein | 813e8cc | 2020-08-05 09:33:38 -0500 | [diff] [blame] | 70 | extern bool gSkVMAllowJIT; |
Mike Klein | ea4459d | 2020-01-16 13:05:04 -0600 | [diff] [blame] | 71 | extern bool gSkVMJITViaDylib; |
Mike Reed | c928fe2 | 2017-06-05 10:20:31 -0400 | [diff] [blame] | 72 | |
Mike Klein | 8f11d4d | 2018-01-24 12:42:55 -0500 | [diff] [blame] | 73 | #ifndef SK_BUILD_FOR_WIN |
scroggo | 38ce0a7 | 2016-01-07 07:28:47 -0800 | [diff] [blame] | 74 | #include <unistd.h> |
Brian Salomon | 032aaae | 2018-03-23 16:10:36 -0400 | [diff] [blame] | 75 | |
scroggo | 38ce0a7 | 2016-01-07 07:28:47 -0800 | [diff] [blame] | 76 | #endif |
| 77 | |
Robert Phillips | 00f78de | 2020-07-01 16:09:43 -0400 | [diff] [blame] | 78 | #include "include/gpu/GrDirectContext.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 79 | #include "src/gpu/GrCaps.h" |
Adlai Holler | a069304 | 2020-10-14 11:23:11 -0400 | [diff] [blame] | 80 | #include "src/gpu/GrDirectContextPriv.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 81 | #include "src/gpu/SkGr.h" |
| 82 | #include "src/gpu/gl/GrGLDefines.h" |
| 83 | #include "src/gpu/gl/GrGLGpu.h" |
| 84 | #include "src/gpu/gl/GrGLUtil.h" |
| 85 | #include "tools/gpu/GrContextFactory.h" |
Brian Salomon | 032aaae | 2018-03-23 16:10:36 -0400 | [diff] [blame] | 86 | |
Brian Osman | c7ad40f | 2018-05-31 14:27:17 -0400 | [diff] [blame] | 87 | using sk_gpu_test::ContextInfo; |
| 88 | using sk_gpu_test::GrContextFactory; |
| 89 | using sk_gpu_test::TestContext; |
Brian Salomon | 032aaae | 2018-03-23 16:10:36 -0400 | [diff] [blame] | 90 | |
Brian Osman | c7ad40f | 2018-05-31 14:27:17 -0400 | [diff] [blame] | 91 | GrContextOptions grContextOpts; |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 92 | |
reed | 5324978 | 2014-10-10 09:09:52 -0700 | [diff] [blame] | 93 | static const int kAutoTuneLoops = 0; |
bsalomon | 6eb03cc | 2014-08-07 14:28:50 -0700 | [diff] [blame] | 94 | |
bsalomon | 6eb03cc | 2014-08-07 14:28:50 -0700 | [diff] [blame] | 95 | static SkString loops_help_txt() { |
| 96 | SkString help; |
| 97 | help.printf("Number of times to run each bench. Set this to %d to auto-" |
| 98 | "tune for each bench. Timings are only reported when auto-tuning.", |
| 99 | kAutoTuneLoops); |
| 100 | return help; |
| 101 | } |
| 102 | |
cdalton | e1b8958 | 2015-06-25 19:17:08 -0700 | [diff] [blame] | 103 | static SkString to_string(int n) { |
| 104 | SkString str; |
| 105 | str.appendS32(n); |
| 106 | return str; |
| 107 | } |
| 108 | |
Mike Klein | ac8f443 | 2019-07-01 10:15:32 -0500 | [diff] [blame] | 109 | static DEFINE_int(loops, kAutoTuneLoops, loops_help_txt().c_str()); |
bsalomon | 6eb03cc | 2014-08-07 14:28:50 -0700 | [diff] [blame] | 110 | |
Mike Klein | 5b3f343 | 2019-03-21 11:42:21 -0500 | [diff] [blame] | 111 | static DEFINE_int(samples, 10, "Number of samples to measure for each bench."); |
| 112 | static DEFINE_int(ms, 0, "If >0, run each bench for this many ms instead of obeying --samples."); |
| 113 | static DEFINE_int(overheadLoops, 100000, "Loops to estimate timer overhead."); |
Mike Klein | 84836b7 | 2019-03-21 11:31:36 -0500 | [diff] [blame] | 114 | static DEFINE_double(overheadGoal, 0.0001, |
mtklein | f372321 | 2014-06-25 14:08:00 -0700 | [diff] [blame] | 115 | "Loop until timer overhead is at most this fraction of our measurments."); |
Mike Klein | 84836b7 | 2019-03-21 11:31:36 -0500 | [diff] [blame] | 116 | static DEFINE_double(gpuMs, 5, "Target bench time in millseconds for GPU."); |
Mike Klein | 5b3f343 | 2019-03-21 11:42:21 -0500 | [diff] [blame] | 117 | static DEFINE_int(gpuFrameLag, 5, |
Mike Klein | 84836b7 | 2019-03-21 11:31:36 -0500 | [diff] [blame] | 118 | "If unknown, estimated maximum number of frames GPU allows to lag."); |
mtklein | f372321 | 2014-06-25 14:08:00 -0700 | [diff] [blame] | 119 | |
Mike Klein | 84836b7 | 2019-03-21 11:31:36 -0500 | [diff] [blame] | 120 | static DEFINE_string(outResultsFile, "", "If given, write results here as JSON."); |
Mike Klein | 5b3f343 | 2019-03-21 11:42:21 -0500 | [diff] [blame] | 121 | static DEFINE_int(maxCalibrationAttempts, 3, |
mtklein | 55b0ffc | 2014-07-17 08:38:23 -0700 | [diff] [blame] | 122 | "Try up to this many times to guess loops for a bench, or skip the bench."); |
Mike Klein | 5b3f343 | 2019-03-21 11:42:21 -0500 | [diff] [blame] | 123 | static DEFINE_int(maxLoops, 1000000, "Never run a bench more times than this."); |
Mike Klein | 84836b7 | 2019-03-21 11:31:36 -0500 | [diff] [blame] | 124 | static DEFINE_string(clip, "0,0,1000,1000", "Clip for SKPs."); |
| 125 | static DEFINE_string(scales, "1.0", "Space-separated scales for SKPs."); |
| 126 | static DEFINE_string(zoom, "1.0,0", |
| 127 | "Comma-separated zoomMax,zoomPeriodMs factors for a periodic SKP zoom " |
| 128 | "function that ping-pongs between 1.0 and zoomMax."); |
| 129 | static DEFINE_bool(bbh, true, "Build a BBH for SKPs?"); |
Mike Klein | 84836b7 | 2019-03-21 11:31:36 -0500 | [diff] [blame] | 130 | static DEFINE_bool(loopSKP, true, "Loop SKPs like we do for micro benches?"); |
Mike Klein | 5b3f343 | 2019-03-21 11:42:21 -0500 | [diff] [blame] | 131 | static DEFINE_int(flushEvery, 10, "Flush --outResultsFile every Nth run."); |
Mike Klein | 84836b7 | 2019-03-21 11:31:36 -0500 | [diff] [blame] | 132 | static DEFINE_bool(gpuStats, false, "Print GPU stats after each gpu benchmark?"); |
Chris Dalton | 5dfb3f4 | 2021-04-30 17:16:12 -0600 | [diff] [blame] | 133 | static DEFINE_bool(gpuStatsDump, false, "Dump GPU stats after each benchmark to json"); |
| 134 | static DEFINE_bool(dmsaaStatsDump, false, "Dump DMSAA stats after each benchmark to json"); |
Mike Klein | 84836b7 | 2019-03-21 11:31:36 -0500 | [diff] [blame] | 135 | static DEFINE_bool(keepAlive, false, "Print a message every so often so that we don't time out"); |
| 136 | static DEFINE_bool(csv, false, "Print status in CSV format"); |
| 137 | static DEFINE_string(sourceType, "", |
mtklein | 65dfd2f | 2016-02-03 10:40:54 -0800 | [diff] [blame] | 138 | "Apply usual --match rules to source type: bench, gm, skp, image, etc."); |
Mike Klein | 84836b7 | 2019-03-21 11:31:36 -0500 | [diff] [blame] | 139 | static DEFINE_string(benchType, "", |
| 140 | "Apply usual --match rules to bench type: micro, recording, " |
| 141 | "piping, playback, skcodec, etc."); |
mtklein | 65dfd2f | 2016-02-03 10:40:54 -0800 | [diff] [blame] | 142 | |
Mike Klein | 84836b7 | 2019-03-21 11:31:36 -0500 | [diff] [blame] | 143 | static DEFINE_bool(forceRasterPipeline, false, "sets gSkForceRasterPipelineBlitter"); |
Mike Reed | 0e2fb66 | 2021-07-23 11:00:40 -0400 | [diff] [blame] | 144 | static DEFINE_bool(forceRasterPipelineHP, false, "sets gSkForceRasterPipelineBlitter and gForceHighPrecisionRasterPipeline"); |
Mike Klein | 813e8cc | 2020-08-05 09:33:38 -0500 | [diff] [blame] | 145 | static DEFINE_bool(skvm, false, "sets gUseSkVMBlitter"); |
Mike Klein | f2b3f91 | 2021-03-23 14:32:45 -0500 | [diff] [blame] | 146 | static DEFINE_bool(jit, true, "JIT SkVM?"); |
| 147 | static DEFINE_bool(dylib, false, "JIT via dylib (much slower compile but easier to debug/profile)"); |
Mike Reed | c928fe2 | 2017-06-05 10:20:31 -0400 | [diff] [blame] | 148 | |
Mike Klein | 19fb397 | 2019-03-21 13:08:08 -0500 | [diff] [blame] | 149 | static DEFINE_bool2(pre_log, p, false, |
| 150 | "Log before running each test. May be incomprehensible when threading"); |
| 151 | |
Leon Scroggins III | 1ff0706 | 2020-07-27 14:52:19 -0400 | [diff] [blame] | 152 | static DEFINE_bool(cpu, true, "Run CPU-bound work?"); |
| 153 | static DEFINE_bool(gpu, true, "Run GPU-bound work?"); |
Mike Klein | 629f5fc | 2019-03-22 14:55:19 -0500 | [diff] [blame] | 154 | static DEFINE_bool(dryRun, false, |
| 155 | "just print the tests that would be run, without actually running them."); |
| 156 | static DEFINE_string(images, "", |
| 157 | "List of images and/or directories to decode. A directory with no images" |
| 158 | " is treated as a fatal error."); |
| 159 | static DEFINE_bool(simpleCodec, false, |
| 160 | "Runs of a subset of the codec tests, always N32, Premul or Opaque"); |
| 161 | |
Mike Klein | c6142d8 | 2019-03-25 10:54:59 -0500 | [diff] [blame] | 162 | static DEFINE_string2(match, m, nullptr, |
| 163 | "[~][^]substring[$] [...] of name to run.\n" |
| 164 | "Multiple matches may be separated by spaces.\n" |
| 165 | "~ causes a matching name to always be skipped\n" |
| 166 | "^ requires the start of the name to match\n" |
| 167 | "$ requires the end of the name to match\n" |
| 168 | "^ and $ requires an exact match\n" |
| 169 | "If a name does not match any list entry,\n" |
| 170 | "it is skipped unless some list entry starts with ~"); |
| 171 | |
| 172 | static DEFINE_bool2(quiet, q, false, "if true, don't print status updates."); |
| 173 | static DEFINE_bool2(verbose, v, false, "enable verbose output from the test driver."); |
| 174 | |
| 175 | |
| 176 | static DEFINE_string(skps, "skps", "Directory to read skps from."); |
Brian Salomon | 31fddc3 | 2021-04-30 13:08:55 -0400 | [diff] [blame] | 177 | static DEFINE_string(mskps, "mskps", "Directory to read mskps from."); |
Mike Klein | c6142d8 | 2019-03-25 10:54:59 -0500 | [diff] [blame] | 178 | static DEFINE_string(svgs, "", "Directory to read SVGs from, or a single SVG file."); |
Hal Canary | 5dfefa2 | 2019-10-24 13:52:17 -0400 | [diff] [blame] | 179 | static DEFINE_string(texttraces, "", "Directory to read TextBlobTrace files from."); |
Mike Klein | c6142d8 | 2019-03-25 10:54:59 -0500 | [diff] [blame] | 180 | |
| 181 | static DEFINE_int_2(threads, j, -1, |
| 182 | "Run threadsafe tests on a threadpool with this many extra threads, " |
| 183 | "defaulting to one extra thread per core."); |
| 184 | |
| 185 | static DEFINE_string2(writePath, w, "", "If set, write bitmaps here as .pngs."); |
| 186 | |
| 187 | static DEFINE_string(key, "", |
| 188 | "Space-separated key/value pairs to add to JSON identifying this builder."); |
| 189 | static DEFINE_string(properties, "", |
| 190 | "Space-separated key/value pairs to add to JSON identifying this run."); |
| 191 | |
Mike Klein | ee25423 | 2019-03-28 08:32:14 -0500 | [diff] [blame] | 192 | static DEFINE_bool(purgeBetweenBenches, false, |
| 193 | "Call SkGraphics::PurgeAllCaches() between each benchmark?"); |
| 194 | |
mtklein | bbba168 | 2015-10-28 11:36:30 -0700 | [diff] [blame] | 195 | static double now_ms() { return SkTime::GetNSecs() * 1e-6; } |
| 196 | |
mtklein | f372321 | 2014-06-25 14:08:00 -0700 | [diff] [blame] | 197 | static SkString humanize(double ms) { |
Adlai Holler | 684838f | 2020-05-12 10:41:04 -0400 | [diff] [blame] | 198 | if (FLAGS_verbose) return SkStringPrintf("%" PRIu64, (uint64_t)(ms*1e6)); |
mtklein | 748ca3b | 2015-01-15 10:56:12 -0800 | [diff] [blame] | 199 | return HumanizeMs(ms); |
mtklein | f372321 | 2014-06-25 14:08:00 -0700 | [diff] [blame] | 200 | } |
mtklein | 55b0ffc | 2014-07-17 08:38:23 -0700 | [diff] [blame] | 201 | #define HUMANIZE(ms) humanize(ms).c_str() |
mtklein | f372321 | 2014-06-25 14:08:00 -0700 | [diff] [blame] | 202 | |
tomhudson | d968a6f | 2015-03-26 11:28:06 -0700 | [diff] [blame] | 203 | bool Target::init(SkImageInfo info, Benchmark* bench) { |
| 204 | if (Benchmark::kRaster_Backend == config.backend) { |
reed | e8f3062 | 2016-03-23 18:59:25 -0700 | [diff] [blame] | 205 | this->surface = SkSurface::MakeRaster(info); |
| 206 | if (!this->surface) { |
tomhudson | d968a6f | 2015-03-26 11:28:06 -0700 | [diff] [blame] | 207 | return false; |
| 208 | } |
| 209 | } |
| 210 | return true; |
| 211 | } |
| 212 | bool Target::capturePixels(SkBitmap* bmp) { |
tomhudson | 75a0ebb | 2015-03-27 12:11:44 -0700 | [diff] [blame] | 213 | SkCanvas* canvas = this->getCanvas(); |
tomhudson | d968a6f | 2015-03-26 11:28:06 -0700 | [diff] [blame] | 214 | if (!canvas) { |
| 215 | return false; |
| 216 | } |
Mike Reed | 12e946b | 2017-04-17 10:53:29 -0400 | [diff] [blame] | 217 | bmp->allocPixels(canvas->imageInfo()); |
| 218 | if (!canvas->readPixels(*bmp, 0, 0)) { |
tomhudson | d968a6f | 2015-03-26 11:28:06 -0700 | [diff] [blame] | 219 | SkDebugf("Can't read canvas pixels.\n"); |
| 220 | return false; |
| 221 | } |
| 222 | return true; |
| 223 | } |
| 224 | |
tomhudson | d968a6f | 2015-03-26 11:28:06 -0700 | [diff] [blame] | 225 | struct GPUTarget : public Target { |
Brian Salomon | 0b4d8aa | 2017-10-11 15:34:27 -0400 | [diff] [blame] | 226 | explicit GPUTarget(const Config& c) : Target(c) {} |
| 227 | ContextInfo contextInfo; |
| 228 | std::unique_ptr<GrContextFactory> factory; |
tomhudson | d968a6f | 2015-03-26 11:28:06 -0700 | [diff] [blame] | 229 | |
Greg Daniel | 5ed3c11 | 2020-06-18 15:59:17 -0400 | [diff] [blame] | 230 | ~GPUTarget() override { |
| 231 | // For Vulkan we need to release all our refs to the GrContext before destroy the vulkan |
| 232 | // context which happens at the end of this destructor. Thus we need to release the surface |
| 233 | // here which holds a ref to the GrContext. |
| 234 | surface.reset(); |
| 235 | } |
| 236 | |
tomhudson | d968a6f | 2015-03-26 11:28:06 -0700 | [diff] [blame] | 237 | void setup() override { |
Brian Salomon | 0b4d8aa | 2017-10-11 15:34:27 -0400 | [diff] [blame] | 238 | this->contextInfo.testContext()->makeCurrent(); |
tomhudson | d968a6f | 2015-03-26 11:28:06 -0700 | [diff] [blame] | 239 | // Make sure we're done with whatever came before. |
Brian Salomon | 0b4d8aa | 2017-10-11 15:34:27 -0400 | [diff] [blame] | 240 | this->contextInfo.testContext()->finish(); |
tomhudson | d968a6f | 2015-03-26 11:28:06 -0700 | [diff] [blame] | 241 | } |
| 242 | void endTiming() override { |
Brian Salomon | 0b4d8aa | 2017-10-11 15:34:27 -0400 | [diff] [blame] | 243 | if (this->contextInfo.testContext()) { |
Robert Phillips | 00f78de | 2020-07-01 16:09:43 -0400 | [diff] [blame] | 244 | this->contextInfo.testContext()->flushAndWaitOnSync(contextInfo.directContext()); |
tomhudson | d968a6f | 2015-03-26 11:28:06 -0700 | [diff] [blame] | 245 | } |
| 246 | } |
Brian Salomon | 0b4d8aa | 2017-10-11 15:34:27 -0400 | [diff] [blame] | 247 | void fence() override { this->contextInfo.testContext()->finish(); } |
mtklein | d75c466 | 2015-04-30 07:11:22 -0700 | [diff] [blame] | 248 | |
cdalton | d416a5b | 2015-06-23 13:23:44 -0700 | [diff] [blame] | 249 | bool needsFrameTiming(int* maxFrameLag) const override { |
Brian Salomon | 0b4d8aa | 2017-10-11 15:34:27 -0400 | [diff] [blame] | 250 | if (!this->contextInfo.testContext()->getMaxGpuFrameLag(maxFrameLag)) { |
cdalton | d416a5b | 2015-06-23 13:23:44 -0700 | [diff] [blame] | 251 | // Frame lag is unknown. |
| 252 | *maxFrameLag = FLAGS_gpuFrameLag; |
| 253 | } |
| 254 | return true; |
| 255 | } |
tomhudson | d968a6f | 2015-03-26 11:28:06 -0700 | [diff] [blame] | 256 | bool init(SkImageInfo info, Benchmark* bench) override { |
Brian Salomon | 0b4d8aa | 2017-10-11 15:34:27 -0400 | [diff] [blame] | 257 | GrContextOptions options = grContextOpts; |
| 258 | bench->modifyGrContextOptions(&options); |
John Stiles | fbd050b | 2020-08-03 13:21:46 -0400 | [diff] [blame] | 259 | this->factory = std::make_unique<GrContextFactory>(options); |
Chris Dalton | 180b4a1 | 2021-03-16 20:49:15 -0600 | [diff] [blame] | 260 | SkSurfaceProps props(this->config.surfaceFlags, kRGB_H_SkPixelGeometry); |
Brian Salomon | 0b4d8aa | 2017-10-11 15:34:27 -0400 | [diff] [blame] | 261 | this->surface = SkSurface::MakeRenderTarget( |
| 262 | this->factory->get(this->config.ctxType, this->config.ctxOverrides), |
| 263 | SkBudgeted::kNo, info, this->config.samples, &props); |
| 264 | this->contextInfo = |
| 265 | this->factory->getContextInfo(this->config.ctxType, this->config.ctxOverrides); |
John Stiles | a008b0f | 2020-08-16 08:48:02 -0400 | [diff] [blame] | 266 | if (!this->surface) { |
tomhudson | d968a6f | 2015-03-26 11:28:06 -0700 | [diff] [blame] | 267 | return false; |
| 268 | } |
Brian Salomon | 0b4d8aa | 2017-10-11 15:34:27 -0400 | [diff] [blame] | 269 | if (!this->contextInfo.testContext()->fenceSyncSupport()) { |
cdalton | d416a5b | 2015-06-23 13:23:44 -0700 | [diff] [blame] | 270 | SkDebugf("WARNING: GL context for config \"%s\" does not support fence sync. " |
svaisanen | c47635e | 2016-01-28 06:05:43 -0800 | [diff] [blame] | 271 | "Timings might not be accurate.\n", this->config.name.c_str()); |
cdalton | d416a5b | 2015-06-23 13:23:44 -0700 | [diff] [blame] | 272 | } |
tomhudson | d968a6f | 2015-03-26 11:28:06 -0700 | [diff] [blame] | 273 | return true; |
| 274 | } |
Brian Osman | 8c0a1ca | 2019-01-28 14:24:29 -0500 | [diff] [blame] | 275 | void fillOptions(NanoJSONResultsWriter& log) override { |
Brian Salomon | f4ba4ec | 2020-03-19 15:54:28 -0400 | [diff] [blame] | 276 | #ifdef SK_GL |
tomhudson | d968a6f | 2015-03-26 11:28:06 -0700 | [diff] [blame] | 277 | const GrGLubyte* version; |
Greg Daniel | bdf12ad | 2018-10-12 09:31:11 -0400 | [diff] [blame] | 278 | if (this->contextInfo.backend() == GrBackendApi::kOpenGL) { |
Brian Salomon | 032aaae | 2018-03-23 16:10:36 -0400 | [diff] [blame] | 279 | const GrGLInterface* gl = |
Robert Phillips | 00f78de | 2020-07-01 16:09:43 -0400 | [diff] [blame] | 280 | static_cast<GrGLGpu*>(this->contextInfo.directContext()->priv().getGpu()) |
Brian Salomon | 032aaae | 2018-03-23 16:10:36 -0400 | [diff] [blame] | 281 | ->glInterface(); |
bsalomon | c869932 | 2016-05-11 11:55:36 -0700 | [diff] [blame] | 282 | GR_GL_CALL_RET(gl, version, GetString(GR_GL_VERSION)); |
Brian Osman | 8c0a1ca | 2019-01-28 14:24:29 -0500 | [diff] [blame] | 283 | log.appendString("GL_VERSION", (const char*)(version)); |
tomhudson | d968a6f | 2015-03-26 11:28:06 -0700 | [diff] [blame] | 284 | |
bsalomon | c869932 | 2016-05-11 11:55:36 -0700 | [diff] [blame] | 285 | GR_GL_CALL_RET(gl, version, GetString(GR_GL_RENDERER)); |
Brian Osman | 8c0a1ca | 2019-01-28 14:24:29 -0500 | [diff] [blame] | 286 | log.appendString("GL_RENDERER", (const char*) version); |
tomhudson | d968a6f | 2015-03-26 11:28:06 -0700 | [diff] [blame] | 287 | |
bsalomon | c869932 | 2016-05-11 11:55:36 -0700 | [diff] [blame] | 288 | GR_GL_CALL_RET(gl, version, GetString(GR_GL_VENDOR)); |
Brian Osman | 8c0a1ca | 2019-01-28 14:24:29 -0500 | [diff] [blame] | 289 | log.appendString("GL_VENDOR", (const char*) version); |
tomhudson | d968a6f | 2015-03-26 11:28:06 -0700 | [diff] [blame] | 290 | |
bsalomon | c869932 | 2016-05-11 11:55:36 -0700 | [diff] [blame] | 291 | GR_GL_CALL_RET(gl, version, GetString(GR_GL_SHADING_LANGUAGE_VERSION)); |
Brian Osman | 8c0a1ca | 2019-01-28 14:24:29 -0500 | [diff] [blame] | 292 | log.appendString("GL_SHADING_LANGUAGE_VERSION", (const char*) version); |
bsalomon | c869932 | 2016-05-11 11:55:36 -0700 | [diff] [blame] | 293 | } |
Brian Salomon | f4ba4ec | 2020-03-19 15:54:28 -0400 | [diff] [blame] | 294 | #endif |
tomhudson | d968a6f | 2015-03-26 11:28:06 -0700 | [diff] [blame] | 295 | } |
Brian Salomon | 0b4d8aa | 2017-10-11 15:34:27 -0400 | [diff] [blame] | 296 | |
| 297 | void dumpStats() override { |
Robert Phillips | 00f78de | 2020-07-01 16:09:43 -0400 | [diff] [blame] | 298 | auto context = this->contextInfo.directContext(); |
| 299 | |
| 300 | context->priv().printCacheStats(); |
| 301 | context->priv().printGpuStats(); |
| 302 | context->priv().printContextStats(); |
Brian Salomon | 0b4d8aa | 2017-10-11 15:34:27 -0400 | [diff] [blame] | 303 | } |
tomhudson | d968a6f | 2015-03-26 11:28:06 -0700 | [diff] [blame] | 304 | }; |
mtklein | d75c466 | 2015-04-30 07:11:22 -0700 | [diff] [blame] | 305 | |
tomhudson | 75a0ebb | 2015-03-27 12:11:44 -0700 | [diff] [blame] | 306 | static double time(int loops, Benchmark* bench, Target* target) { |
| 307 | SkCanvas* canvas = target->getCanvas(); |
bsalomon | 6eb03cc | 2014-08-07 14:28:50 -0700 | [diff] [blame] | 308 | if (canvas) { |
| 309 | canvas->clear(SK_ColorWHITE); |
| 310 | } |
joshualitt | 8a6697a | 2015-09-30 12:11:07 -0700 | [diff] [blame] | 311 | bench->preDraw(canvas); |
mtklein | bbba168 | 2015-10-28 11:36:30 -0700 | [diff] [blame] | 312 | double start = now_ms(); |
tomhudson | 75a0ebb | 2015-03-27 12:11:44 -0700 | [diff] [blame] | 313 | canvas = target->beginTiming(canvas); |
| 314 | bench->draw(loops, canvas); |
tomhudson | 75a0ebb | 2015-03-27 12:11:44 -0700 | [diff] [blame] | 315 | target->endTiming(); |
mtklein | bbba168 | 2015-10-28 11:36:30 -0700 | [diff] [blame] | 316 | double elapsed = now_ms() - start; |
joshualitt | 8a6697a | 2015-09-30 12:11:07 -0700 | [diff] [blame] | 317 | bench->postDraw(canvas); |
mtklein | bbba168 | 2015-10-28 11:36:30 -0700 | [diff] [blame] | 318 | return elapsed; |
mtklein | bb6a028 | 2014-07-01 08:43:42 -0700 | [diff] [blame] | 319 | } |
| 320 | |
mtklein | f372321 | 2014-06-25 14:08:00 -0700 | [diff] [blame] | 321 | static double estimate_timer_overhead() { |
| 322 | double overhead = 0; |
mtklein | f372321 | 2014-06-25 14:08:00 -0700 | [diff] [blame] | 323 | for (int i = 0; i < FLAGS_overheadLoops; i++) { |
mtklein | bbba168 | 2015-10-28 11:36:30 -0700 | [diff] [blame] | 324 | double start = now_ms(); |
| 325 | overhead += now_ms() - start; |
mtklein | f372321 | 2014-06-25 14:08:00 -0700 | [diff] [blame] | 326 | } |
| 327 | return overhead / FLAGS_overheadLoops; |
| 328 | } |
| 329 | |
reed | 5324978 | 2014-10-10 09:09:52 -0700 | [diff] [blame] | 330 | static int detect_forever_loops(int loops) { |
| 331 | // look for a magic run-forever value |
| 332 | if (loops < 0) { |
| 333 | loops = SK_MaxS32; |
| 334 | } |
| 335 | return loops; |
| 336 | } |
| 337 | |
mtklein | 55b0ffc | 2014-07-17 08:38:23 -0700 | [diff] [blame] | 338 | static int clamp_loops(int loops) { |
| 339 | if (loops < 1) { |
mtklein | 527930f | 2014-11-06 08:04:34 -0800 | [diff] [blame] | 340 | SkDebugf("ERROR: clamping loops from %d to 1. " |
| 341 | "There's probably something wrong with the bench.\n", loops); |
mtklein | 55b0ffc | 2014-07-17 08:38:23 -0700 | [diff] [blame] | 342 | return 1; |
| 343 | } |
| 344 | if (loops > FLAGS_maxLoops) { |
| 345 | SkDebugf("WARNING: clamping loops from %d to FLAGS_maxLoops, %d.\n", loops, FLAGS_maxLoops); |
| 346 | return FLAGS_maxLoops; |
| 347 | } |
| 348 | return loops; |
| 349 | } |
| 350 | |
tomhudson | d968a6f | 2015-03-26 11:28:06 -0700 | [diff] [blame] | 351 | static bool write_canvas_png(Target* target, const SkString& filename) { |
| 352 | |
bsalomon | 6eb03cc | 2014-08-07 14:28:50 -0700 | [diff] [blame] | 353 | if (filename.isEmpty()) { |
| 354 | return false; |
| 355 | } |
tomhudson | 75a0ebb | 2015-03-27 12:11:44 -0700 | [diff] [blame] | 356 | if (target->getCanvas() && |
| 357 | kUnknown_SkColorType == target->getCanvas()->imageInfo().colorType()) { |
bsalomon | 6eb03cc | 2014-08-07 14:28:50 -0700 | [diff] [blame] | 358 | return false; |
| 359 | } |
tomhudson | d968a6f | 2015-03-26 11:28:06 -0700 | [diff] [blame] | 360 | |
bsalomon | 6eb03cc | 2014-08-07 14:28:50 -0700 | [diff] [blame] | 361 | SkBitmap bmp; |
tomhudson | d968a6f | 2015-03-26 11:28:06 -0700 | [diff] [blame] | 362 | |
| 363 | if (!target->capturePixels(&bmp)) { |
bsalomon | 6eb03cc | 2014-08-07 14:28:50 -0700 | [diff] [blame] | 364 | return false; |
| 365 | } |
tomhudson | d968a6f | 2015-03-26 11:28:06 -0700 | [diff] [blame] | 366 | |
bsalomon | 6eb03cc | 2014-08-07 14:28:50 -0700 | [diff] [blame] | 367 | SkString dir = SkOSPath::Dirname(filename.c_str()); |
| 368 | if (!sk_mkdir(dir.c_str())) { |
| 369 | SkDebugf("Can't make dir %s.\n", dir.c_str()); |
| 370 | return false; |
| 371 | } |
| 372 | SkFILEWStream stream(filename.c_str()); |
| 373 | if (!stream.isValid()) { |
| 374 | SkDebugf("Can't write %s.\n", filename.c_str()); |
| 375 | return false; |
| 376 | } |
Hal Canary | db68301 | 2016-11-23 08:55:18 -0700 | [diff] [blame] | 377 | if (!SkEncodeImage(&stream, bmp, SkEncodedImageFormat::kPNG, 100)) { |
bsalomon | 6eb03cc | 2014-08-07 14:28:50 -0700 | [diff] [blame] | 378 | SkDebugf("Can't encode a PNG.\n"); |
| 379 | return false; |
| 380 | } |
| 381 | return true; |
| 382 | } |
| 383 | |
| 384 | static int kFailedLoops = -2; |
cdalton | e1b8958 | 2015-06-25 19:17:08 -0700 | [diff] [blame] | 385 | static int setup_cpu_bench(const double overhead, Target* target, Benchmark* bench) { |
mtklein | bb6a028 | 2014-07-01 08:43:42 -0700 | [diff] [blame] | 386 | // First figure out approximately how many loops of bench it takes to make overhead negligible. |
mtklein | 2069e22 | 2014-08-04 13:57:39 -0700 | [diff] [blame] | 387 | double bench_plus_overhead = 0.0; |
mtklein | 55b0ffc | 2014-07-17 08:38:23 -0700 | [diff] [blame] | 388 | int round = 0; |
cdalton | b402296 | 2015-06-25 10:51:56 -0700 | [diff] [blame] | 389 | int loops = bench->calculateLoops(FLAGS_loops); |
| 390 | if (kAutoTuneLoops == loops) { |
bsalomon | 6eb03cc | 2014-08-07 14:28:50 -0700 | [diff] [blame] | 391 | while (bench_plus_overhead < overhead) { |
| 392 | if (round++ == FLAGS_maxCalibrationAttempts) { |
| 393 | SkDebugf("WARNING: Can't estimate loops for %s (%s vs. %s); skipping.\n", |
mtklein | 9628905 | 2014-09-10 12:05:59 -0700 | [diff] [blame] | 394 | bench->getUniqueName(), HUMANIZE(bench_plus_overhead), HUMANIZE(overhead)); |
bsalomon | 6eb03cc | 2014-08-07 14:28:50 -0700 | [diff] [blame] | 395 | return kFailedLoops; |
| 396 | } |
tomhudson | 75a0ebb | 2015-03-27 12:11:44 -0700 | [diff] [blame] | 397 | bench_plus_overhead = time(1, bench, target); |
mtklein | 55b0ffc | 2014-07-17 08:38:23 -0700 | [diff] [blame] | 398 | } |
mtklein | 2069e22 | 2014-08-04 13:57:39 -0700 | [diff] [blame] | 399 | } |
mtklein | f372321 | 2014-06-25 14:08:00 -0700 | [diff] [blame] | 400 | |
mtklein | bb6a028 | 2014-07-01 08:43:42 -0700 | [diff] [blame] | 401 | // Later we'll just start and stop the timer once but loop N times. |
mtklein | f372321 | 2014-06-25 14:08:00 -0700 | [diff] [blame] | 402 | // We'll pick N to make timer overhead negligible: |
| 403 | // |
mtklein | bb6a028 | 2014-07-01 08:43:42 -0700 | [diff] [blame] | 404 | // overhead |
| 405 | // ------------------------- < FLAGS_overheadGoal |
| 406 | // overhead + N * Bench Time |
mtklein | f372321 | 2014-06-25 14:08:00 -0700 | [diff] [blame] | 407 | // |
Hal Canary | 55325b7 | 2017-01-03 10:36:17 -0500 | [diff] [blame] | 408 | // where bench_plus_overhead ~=~ overhead + Bench Time. |
mtklein | f372321 | 2014-06-25 14:08:00 -0700 | [diff] [blame] | 409 | // |
| 410 | // Doing some math, we get: |
| 411 | // |
mtklein | bb6a028 | 2014-07-01 08:43:42 -0700 | [diff] [blame] | 412 | // (overhead / FLAGS_overheadGoal) - overhead |
| 413 | // ------------------------------------------ < N |
| 414 | // bench_plus_overhead - overhead) |
mtklein | f372321 | 2014-06-25 14:08:00 -0700 | [diff] [blame] | 415 | // |
| 416 | // Luckily, this also works well in practice. :) |
bsalomon | 6eb03cc | 2014-08-07 14:28:50 -0700 | [diff] [blame] | 417 | if (kAutoTuneLoops == loops) { |
| 418 | const double numer = overhead / FLAGS_overheadGoal - overhead; |
| 419 | const double denom = bench_plus_overhead - overhead; |
| 420 | loops = (int)ceil(numer / denom); |
reed | 5324978 | 2014-10-10 09:09:52 -0700 | [diff] [blame] | 421 | loops = clamp_loops(loops); |
| 422 | } else { |
| 423 | loops = detect_forever_loops(loops); |
bsalomon | 6eb03cc | 2014-08-07 14:28:50 -0700 | [diff] [blame] | 424 | } |
mtklein | bb6a028 | 2014-07-01 08:43:42 -0700 | [diff] [blame] | 425 | |
mtklein | bb6a028 | 2014-07-01 08:43:42 -0700 | [diff] [blame] | 426 | return loops; |
mtklein | f372321 | 2014-06-25 14:08:00 -0700 | [diff] [blame] | 427 | } |
| 428 | |
cdalton | e1b8958 | 2015-06-25 19:17:08 -0700 | [diff] [blame] | 429 | static int setup_gpu_bench(Target* target, Benchmark* bench, int maxGpuFrameLag) { |
mtklein | bb6a028 | 2014-07-01 08:43:42 -0700 | [diff] [blame] | 430 | // First, figure out how many loops it'll take to get a frame up to FLAGS_gpuMs. |
cdalton | b402296 | 2015-06-25 10:51:56 -0700 | [diff] [blame] | 431 | int loops = bench->calculateLoops(FLAGS_loops); |
bsalomon | 6eb03cc | 2014-08-07 14:28:50 -0700 | [diff] [blame] | 432 | if (kAutoTuneLoops == loops) { |
| 433 | loops = 1; |
mtklein | a189ccd | 2014-07-14 12:28:47 -0700 | [diff] [blame] | 434 | double elapsed = 0; |
| 435 | do { |
mtklein | 527930f | 2014-11-06 08:04:34 -0800 | [diff] [blame] | 436 | if (1<<30 == loops) { |
| 437 | // We're about to wrap. Something's wrong with the bench. |
| 438 | loops = 0; |
| 439 | break; |
| 440 | } |
mtklein | a189ccd | 2014-07-14 12:28:47 -0700 | [diff] [blame] | 441 | loops *= 2; |
| 442 | // If the GPU lets frames lag at all, we need to make sure we're timing |
cdalton | d416a5b | 2015-06-23 13:23:44 -0700 | [diff] [blame] | 443 | // _this_ round, not still timing last round. |
| 444 | for (int i = 0; i < maxGpuFrameLag; i++) { |
tomhudson | 75a0ebb | 2015-03-27 12:11:44 -0700 | [diff] [blame] | 445 | elapsed = time(loops, bench, target); |
mtklein | a189ccd | 2014-07-14 12:28:47 -0700 | [diff] [blame] | 446 | } |
| 447 | } while (elapsed < FLAGS_gpuMs); |
mtklein | bb6a028 | 2014-07-01 08:43:42 -0700 | [diff] [blame] | 448 | |
mtklein | a189ccd | 2014-07-14 12:28:47 -0700 | [diff] [blame] | 449 | // We've overshot at least a little. Scale back linearly. |
| 450 | loops = (int)ceil(loops * FLAGS_gpuMs / elapsed); |
reed | 5324978 | 2014-10-10 09:09:52 -0700 | [diff] [blame] | 451 | loops = clamp_loops(loops); |
mtklein | bb6a028 | 2014-07-01 08:43:42 -0700 | [diff] [blame] | 452 | |
tomhudson | d968a6f | 2015-03-26 11:28:06 -0700 | [diff] [blame] | 453 | // Make sure we're not still timing our calibration. |
| 454 | target->fence(); |
reed | 5324978 | 2014-10-10 09:09:52 -0700 | [diff] [blame] | 455 | } else { |
| 456 | loops = detect_forever_loops(loops); |
mtklein | a189ccd | 2014-07-14 12:28:47 -0700 | [diff] [blame] | 457 | } |
mtklein | bb6a028 | 2014-07-01 08:43:42 -0700 | [diff] [blame] | 458 | // Pretty much the same deal as the calibration: do some warmup to make |
| 459 | // sure we're timing steady-state pipelined frames. |
Brian Osman | 0177698 | 2017-10-10 15:41:03 -0400 | [diff] [blame] | 460 | for (int i = 0; i < maxGpuFrameLag; i++) { |
tomhudson | 75a0ebb | 2015-03-27 12:11:44 -0700 | [diff] [blame] | 461 | time(loops, bench, target); |
mtklein | f372321 | 2014-06-25 14:08:00 -0700 | [diff] [blame] | 462 | } |
mtklein | bb6a028 | 2014-07-01 08:43:42 -0700 | [diff] [blame] | 463 | |
mtklein | bb6a028 | 2014-07-01 08:43:42 -0700 | [diff] [blame] | 464 | return loops; |
| 465 | } |
mtklein | bb6a028 | 2014-07-01 08:43:42 -0700 | [diff] [blame] | 466 | |
Brian Salomon | 6405e71 | 2017-03-20 08:54:16 -0400 | [diff] [blame] | 467 | #define kBogusContextType GrContextFactory::kGL_ContextType |
csmartdalton | e812d49 | 2017-02-21 12:36:05 -0700 | [diff] [blame] | 468 | #define kBogusContextOverrides GrContextFactory::ContextOverrides::kNone |
bsalomon | c255337 | 2014-07-22 13:09:05 -0700 | [diff] [blame] | 469 | |
svaisanen | c47635e | 2016-01-28 06:05:43 -0800 | [diff] [blame] | 470 | static void create_config(const SkCommandLineConfig* config, SkTArray<Config>* configs) { |
svaisanen | c47635e | 2016-01-28 06:05:43 -0800 | [diff] [blame] | 471 | if (const auto* gpuConfig = config->asConfigGpu()) { |
Ben Wagner | 32fa510 | 2017-08-10 21:25:55 -0400 | [diff] [blame] | 472 | if (!FLAGS_gpu) { |
| 473 | SkDebugf("Skipping config '%s' as requested.\n", config->getTag().c_str()); |
svaisanen | c47635e | 2016-01-28 06:05:43 -0800 | [diff] [blame] | 474 | return; |
Ben Wagner | 32fa510 | 2017-08-10 21:25:55 -0400 | [diff] [blame] | 475 | } |
svaisanen | c47635e | 2016-01-28 06:05:43 -0800 | [diff] [blame] | 476 | |
svaisanen | c47635e | 2016-01-28 06:05:43 -0800 | [diff] [blame] | 477 | const auto ctxType = gpuConfig->getContextType(); |
csmartdalton | e812d49 | 2017-02-21 12:36:05 -0700 | [diff] [blame] | 478 | const auto ctxOverrides = gpuConfig->getContextOverrides(); |
svaisanen | c47635e | 2016-01-28 06:05:43 -0800 | [diff] [blame] | 479 | const auto sampleCount = gpuConfig->getSamples(); |
Greg Daniel | 81e7bf8 | 2017-07-19 14:47:42 -0400 | [diff] [blame] | 480 | const auto colorType = gpuConfig->getColorType(); |
| 481 | auto colorSpace = gpuConfig->getColorSpace(); |
Brian Salomon | f865b05 | 2018-03-09 09:01:53 -0500 | [diff] [blame] | 482 | if (gpuConfig->getSurfType() != SkCommandLineConfigGpu::SurfType::kDefault) { |
| 483 | SkDebugf("This tool only supports the default surface type."); |
| 484 | return; |
| 485 | } |
svaisanen | c47635e | 2016-01-28 06:05:43 -0800 | [diff] [blame] | 486 | |
Brian Salomon | 0b4d8aa | 2017-10-11 15:34:27 -0400 | [diff] [blame] | 487 | GrContextFactory factory(grContextOpts); |
Robert Phillips | f028810 | 2020-07-06 13:45:34 -0400 | [diff] [blame] | 488 | if (const auto ctx = factory.get(ctxType, ctxOverrides)) { |
Greg Daniel | 6fa62e2 | 2019-08-07 15:52:37 -0400 | [diff] [blame] | 489 | GrBackendFormat format = ctx->defaultBackendFormat(colorType, GrRenderable::kYes); |
Brian Salomon | bdecacf | 2018-02-02 20:32:49 -0500 | [diff] [blame] | 490 | int supportedSampleCount = |
Greg Daniel | 6fa62e2 | 2019-08-07 15:52:37 -0400 | [diff] [blame] | 491 | ctx->priv().caps()->getRenderTargetSampleCount(sampleCount, format); |
Greg Daniel | 81e7bf8 | 2017-07-19 14:47:42 -0400 | [diff] [blame] | 492 | if (sampleCount != supportedSampleCount) { |
Ben Wagner | 32fa510 | 2017-08-10 21:25:55 -0400 | [diff] [blame] | 493 | SkDebugf("Configuration '%s' sample count %d is not a supported sample count.\n", |
| 494 | config->getTag().c_str(), sampleCount); |
svaisanen | c47635e | 2016-01-28 06:05:43 -0800 | [diff] [blame] | 495 | return; |
| 496 | } |
| 497 | } else { |
Ben Wagner | 32fa510 | 2017-08-10 21:25:55 -0400 | [diff] [blame] | 498 | SkDebugf("No context was available matching config '%s'.\n", |
| 499 | config->getTag().c_str()); |
svaisanen | c47635e | 2016-01-28 06:05:43 -0800 | [diff] [blame] | 500 | return; |
| 501 | } |
| 502 | |
| 503 | Config target = { |
kkinnunen | d4e1c35 | 2016-03-01 23:41:26 -0800 | [diff] [blame] | 504 | gpuConfig->getTag(), |
svaisanen | c47635e | 2016-01-28 06:05:43 -0800 | [diff] [blame] | 505 | Benchmark::kGPU_Backend, |
Greg Daniel | 81e7bf8 | 2017-07-19 14:47:42 -0400 | [diff] [blame] | 506 | colorType, |
svaisanen | c47635e | 2016-01-28 06:05:43 -0800 | [diff] [blame] | 507 | kPremul_SkAlphaType, |
Greg Daniel | 81e7bf8 | 2017-07-19 14:47:42 -0400 | [diff] [blame] | 508 | sk_ref_sp(colorSpace), |
svaisanen | c47635e | 2016-01-28 06:05:43 -0800 | [diff] [blame] | 509 | sampleCount, |
| 510 | ctxType, |
csmartdalton | e812d49 | 2017-02-21 12:36:05 -0700 | [diff] [blame] | 511 | ctxOverrides, |
Chris Dalton | 180b4a1 | 2021-03-16 20:49:15 -0600 | [diff] [blame] | 512 | gpuConfig->getSurfaceFlags() |
kkinnunen | d4e1c35 | 2016-03-01 23:41:26 -0800 | [diff] [blame] | 513 | }; |
svaisanen | c47635e | 2016-01-28 06:05:43 -0800 | [diff] [blame] | 514 | |
| 515 | configs->push_back(target); |
| 516 | return; |
| 517 | } |
svaisanen | c47635e | 2016-01-28 06:05:43 -0800 | [diff] [blame] | 518 | |
brianosman | b109b8c | 2016-06-16 13:03:24 -0700 | [diff] [blame] | 519 | #define CPU_CONFIG(name, backend, color, alpha, colorSpace) \ |
| 520 | if (config->getTag().equals(#name)) { \ |
Ben Wagner | 32fa510 | 2017-08-10 21:25:55 -0400 | [diff] [blame] | 521 | if (!FLAGS_cpu) { \ |
| 522 | SkDebugf("Skipping config '%s' as requested.\n", \ |
| 523 | config->getTag().c_str()); \ |
| 524 | return; \ |
| 525 | } \ |
brianosman | b109b8c | 2016-06-16 13:03:24 -0700 | [diff] [blame] | 526 | Config config = { \ |
| 527 | SkString(#name), Benchmark::backend, color, alpha, colorSpace, \ |
Chris Dalton | 94df572 | 2021-04-19 17:40:40 -0600 | [diff] [blame] | 528 | 0, kBogusContextType, kBogusContextOverrides, 0 \ |
brianosman | b109b8c | 2016-06-16 13:03:24 -0700 | [diff] [blame] | 529 | }; \ |
| 530 | configs->push_back(config); \ |
| 531 | return; \ |
mtklein | bb6a028 | 2014-07-01 08:43:42 -0700 | [diff] [blame] | 532 | } |
mtklein | e714e75 | 2014-07-31 12:13:48 -0700 | [diff] [blame] | 533 | |
Ben Wagner | 32fa510 | 2017-08-10 21:25:55 -0400 | [diff] [blame] | 534 | CPU_CONFIG(nonrendering, kNonRendering_Backend, |
| 535 | kUnknown_SkColorType, kUnpremul_SkAlphaType, nullptr) |
mtklein | bb6c41b | 2016-03-08 11:31:11 -0800 | [diff] [blame] | 536 | |
Mike Klein | 0e4041f | 2018-06-19 16:00:40 -0400 | [diff] [blame] | 537 | CPU_CONFIG(a8, kRaster_Backend, kAlpha_8_SkColorType, kPremul_SkAlphaType, nullptr) |
| 538 | CPU_CONFIG(8888, kRaster_Backend, kN32_SkColorType, kPremul_SkAlphaType, nullptr) |
| 539 | CPU_CONFIG(565, kRaster_Backend, kRGB_565_SkColorType, kOpaque_SkAlphaType, nullptr) |
| 540 | |
| 541 | // 'narrow' has a gamut narrower than sRGB, and different transfer function. |
Brian Osman | 82ebe04 | 2019-01-04 17:03:00 -0500 | [diff] [blame] | 542 | auto narrow = SkColorSpace::MakeRGB(SkNamedTransferFn::k2Dot2, gNarrow_toXYZD50), |
Mike Klein | 0e4041f | 2018-06-19 16:00:40 -0400 | [diff] [blame] | 543 | srgb = SkColorSpace::MakeSRGB(), |
| 544 | srgbLinear = SkColorSpace::MakeSRGBLinear(); |
| 545 | |
| 546 | CPU_CONFIG( f16, kRaster_Backend, kRGBA_F16_SkColorType, kPremul_SkAlphaType, srgbLinear) |
| 547 | CPU_CONFIG( srgb, kRaster_Backend, kRGBA_8888_SkColorType, kPremul_SkAlphaType, srgb ) |
| 548 | CPU_CONFIG( esrgb, kRaster_Backend, kRGBA_F16_SkColorType, kPremul_SkAlphaType, srgb ) |
| 549 | CPU_CONFIG( narrow, kRaster_Backend, kRGBA_8888_SkColorType, kPremul_SkAlphaType, narrow ) |
| 550 | CPU_CONFIG(enarrow, kRaster_Backend, kRGBA_F16_SkColorType, kPremul_SkAlphaType, narrow ) |
mtklein | bb6a028 | 2014-07-01 08:43:42 -0700 | [diff] [blame] | 551 | |
svaisanen | c47635e | 2016-01-28 06:05:43 -0800 | [diff] [blame] | 552 | #undef CPU_CONFIG |
Ben Wagner | 32fa510 | 2017-08-10 21:25:55 -0400 | [diff] [blame] | 553 | |
| 554 | SkDebugf("Unknown config '%s'.\n", config->getTag().c_str()); |
mtklein | f372321 | 2014-06-25 14:08:00 -0700 | [diff] [blame] | 555 | } |
| 556 | |
svaisanen | c47635e | 2016-01-28 06:05:43 -0800 | [diff] [blame] | 557 | // Append all configs that are enabled and supported. |
| 558 | void create_configs(SkTArray<Config>* configs) { |
| 559 | SkCommandLineConfigArray array; |
| 560 | ParseConfigs(FLAGS_config, &array); |
| 561 | for (int i = 0; i < array.count(); ++i) { |
Ben Wagner | 145dbcd | 2016-11-03 14:40:50 -0400 | [diff] [blame] | 562 | create_config(array[i].get(), configs); |
svaisanen | c47635e | 2016-01-28 06:05:43 -0800 | [diff] [blame] | 563 | } |
Ben Wagner | 32fa510 | 2017-08-10 21:25:55 -0400 | [diff] [blame] | 564 | |
| 565 | // If no just default configs were requested, then we're okay. |
| 566 | if (array.count() == 0 || FLAGS_config.count() == 0 || |
Ben Wagner | 32fa510 | 2017-08-10 21:25:55 -0400 | [diff] [blame] | 567 | // Otherwise, make sure that all specified configs have been created. |
| 568 | array.count() == configs->count()) { |
| 569 | return; |
| 570 | } |
Ben Wagner | 32fa510 | 2017-08-10 21:25:55 -0400 | [diff] [blame] | 571 | exit(1); |
svaisanen | c47635e | 2016-01-28 06:05:43 -0800 | [diff] [blame] | 572 | } |
| 573 | |
brianosman | 9f1f6e2 | 2016-09-15 08:33:02 -0700 | [diff] [blame] | 574 | // disable warning : switch statement contains default but no 'case' labels |
| 575 | #if defined _WIN32 |
| 576 | #pragma warning ( push ) |
| 577 | #pragma warning ( disable : 4065 ) |
| 578 | #endif |
| 579 | |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 580 | // If bench is enabled for config, returns a Target* for it, otherwise nullptr. |
bsalomon | c255337 | 2014-07-22 13:09:05 -0700 | [diff] [blame] | 581 | static Target* is_enabled(Benchmark* bench, const Config& config) { |
| 582 | if (!bench->isSuitableFor(config.backend)) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 583 | return nullptr; |
bsalomon | c255337 | 2014-07-22 13:09:05 -0700 | [diff] [blame] | 584 | } |
| 585 | |
reed | e5ea500 | 2014-09-03 11:54:58 -0700 | [diff] [blame] | 586 | SkImageInfo info = SkImageInfo::Make(bench->getSize().fX, bench->getSize().fY, |
brianosman | b109b8c | 2016-06-16 13:03:24 -0700 | [diff] [blame] | 587 | config.color, config.alpha, config.colorSpace); |
bsalomon | c255337 | 2014-07-22 13:09:05 -0700 | [diff] [blame] | 588 | |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 589 | Target* target = nullptr; |
bsalomon | c255337 | 2014-07-22 13:09:05 -0700 | [diff] [blame] | 590 | |
tomhudson | d968a6f | 2015-03-26 11:28:06 -0700 | [diff] [blame] | 591 | switch (config.backend) { |
tomhudson | d968a6f | 2015-03-26 11:28:06 -0700 | [diff] [blame] | 592 | case Benchmark::kGPU_Backend: |
| 593 | target = new GPUTarget(config); |
| 594 | break; |
tomhudson | d968a6f | 2015-03-26 11:28:06 -0700 | [diff] [blame] | 595 | default: |
| 596 | target = new Target(config); |
| 597 | break; |
| 598 | } |
bsalomon | c255337 | 2014-07-22 13:09:05 -0700 | [diff] [blame] | 599 | |
tomhudson | d968a6f | 2015-03-26 11:28:06 -0700 | [diff] [blame] | 600 | if (!target->init(info, bench)) { |
bsalomon | c255337 | 2014-07-22 13:09:05 -0700 | [diff] [blame] | 601 | delete target; |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 602 | return nullptr; |
bsalomon | c255337 | 2014-07-22 13:09:05 -0700 | [diff] [blame] | 603 | } |
| 604 | return target; |
| 605 | } |
| 606 | |
brianosman | 9f1f6e2 | 2016-09-15 08:33:02 -0700 | [diff] [blame] | 607 | #if defined _WIN32 |
| 608 | #pragma warning ( pop ) |
| 609 | #endif |
| 610 | |
Leon Scroggins III | 87caae6 | 2020-05-04 10:02:45 -0400 | [diff] [blame] | 611 | #ifdef SK_ENABLE_ANDROID_UTILS |
reed | 42943c8 | 2016-09-12 12:01:44 -0700 | [diff] [blame] | 612 | static bool valid_brd_bench(sk_sp<SkData> encoded, SkColorType colorType, uint32_t sampleSize, |
msarett | d1227a7 | 2016-05-18 06:23:57 -0700 | [diff] [blame] | 613 | uint32_t minOutputSize, int* width, int* height) { |
Leon Scroggins III | 87caae6 | 2020-05-04 10:02:45 -0400 | [diff] [blame] | 614 | auto brd = android::skia::BitmapRegionDecoder::Make(encoded); |
John Stiles | a008b0f | 2020-08-16 08:48:02 -0400 | [diff] [blame] | 615 | if (nullptr == brd) { |
msarett | 7f69144 | 2015-09-22 11:56:16 -0700 | [diff] [blame] | 616 | // This is indicates that subset decoding is not supported for a particular image format. |
| 617 | return false; |
| 618 | } |
| 619 | |
msarett | 7f69144 | 2015-09-22 11:56:16 -0700 | [diff] [blame] | 620 | if (sampleSize * minOutputSize > (uint32_t) brd->width() || sampleSize * minOutputSize > |
| 621 | (uint32_t) brd->height()) { |
| 622 | // This indicates that the image is not large enough to decode a |
| 623 | // minOutputSize x minOutputSize subset at the given sampleSize. |
| 624 | return false; |
| 625 | } |
| 626 | |
| 627 | // Set the image width and height. The calling code will use this to choose subsets to decode. |
| 628 | *width = brd->width(); |
| 629 | *height = brd->height(); |
| 630 | return true; |
| 631 | } |
Leon Scroggins III | 87caae6 | 2020-05-04 10:02:45 -0400 | [diff] [blame] | 632 | #endif |
msarett | 7f69144 | 2015-09-22 11:56:16 -0700 | [diff] [blame] | 633 | |
egdaniel | 3bf9206 | 2015-06-26 08:12:46 -0700 | [diff] [blame] | 634 | static void cleanup_run(Target* target) { |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 635 | delete target; |
egdaniel | 3bf9206 | 2015-06-26 08:12:46 -0700 | [diff] [blame] | 636 | } |
| 637 | |
Mike Klein | 88544fb | 2019-03-20 10:50:33 -0500 | [diff] [blame] | 638 | static void collect_files(const CommandLineFlags::StringArray& paths, |
| 639 | const char* ext, |
| 640 | SkTArray<SkString>* list) { |
fmalita | 6519c21 | 2016-09-14 08:05:17 -0700 | [diff] [blame] | 641 | for (int i = 0; i < paths.count(); ++i) { |
| 642 | if (SkStrEndsWith(paths[i], ext)) { |
| 643 | list->push_back(SkString(paths[i])); |
| 644 | } else { |
| 645 | SkOSFile::Iter it(paths[i], ext); |
| 646 | SkString path; |
| 647 | while (it.next(&path)) { |
| 648 | list->push_back(SkOSPath::Join(paths[i], path.c_str())); |
| 649 | } |
| 650 | } |
| 651 | } |
| 652 | } |
| 653 | |
mtklein | e714e75 | 2014-07-31 12:13:48 -0700 | [diff] [blame] | 654 | class BenchmarkStream { |
| 655 | public: |
mtklein | 9200758 | 2014-08-01 07:46:52 -0700 | [diff] [blame] | 656 | BenchmarkStream() : fBenches(BenchRegistry::Head()) |
Hal Canary | 2362ae7 | 2019-10-24 13:40:40 -0400 | [diff] [blame] | 657 | , fGMs(skiagm::GMRegistry::Head()) { |
fmalita | 6519c21 | 2016-09-14 08:05:17 -0700 | [diff] [blame] | 658 | collect_files(FLAGS_skps, ".skp", &fSKPs); |
Brian Salomon | 31fddc3 | 2021-04-30 13:08:55 -0400 | [diff] [blame] | 659 | collect_files(FLAGS_mskps, ".mskp", &fMSKPs); |
fmalita | 6519c21 | 2016-09-14 08:05:17 -0700 | [diff] [blame] | 660 | collect_files(FLAGS_svgs, ".svg", &fSVGs); |
Hal Canary | 5dfefa2 | 2019-10-24 13:52:17 -0400 | [diff] [blame] | 661 | collect_files(FLAGS_texttraces, ".trace", &fTextBlobTraces); |
mtklein | e714e75 | 2014-07-31 12:13:48 -0700 | [diff] [blame] | 662 | |
mtklein | 9200758 | 2014-08-01 07:46:52 -0700 | [diff] [blame] | 663 | if (4 != sscanf(FLAGS_clip[0], "%d,%d,%d,%d", |
| 664 | &fClip.fLeft, &fClip.fTop, &fClip.fRight, &fClip.fBottom)) { |
| 665 | SkDebugf("Can't parse %s from --clip as an SkIRect.\n", FLAGS_clip[0]); |
| 666 | exit(1); |
| 667 | } |
| 668 | |
| 669 | for (int i = 0; i < FLAGS_scales.count(); i++) { |
| 670 | if (1 != sscanf(FLAGS_scales[i], "%f", &fScales.push_back())) { |
| 671 | SkDebugf("Can't parse %s from --scales as an SkScalar.\n", FLAGS_scales[i]); |
| 672 | exit(1); |
| 673 | } |
| 674 | } |
robertphillips | 5b69377 | 2014-11-21 06:19:36 -0800 | [diff] [blame] | 675 | |
cdalton | 63a8285 | 2015-06-29 14:06:10 -0700 | [diff] [blame] | 676 | if (2 != sscanf(FLAGS_zoom[0], "%f,%lf", &fZoomMax, &fZoomPeriodMs)) { |
| 677 | SkDebugf("Can't parse %s from --zoom as a zoomMax,zoomPeriodMs.\n", FLAGS_zoom[0]); |
joshualitt | 261c3ad | 2015-04-27 09:16:57 -0700 | [diff] [blame] | 678 | exit(1); |
| 679 | } |
| 680 | |
msarett | 95f192d | 2015-02-13 09:05:41 -0800 | [diff] [blame] | 681 | // Prepare the images for decoding |
msarett | 69deca8 | 2016-04-29 09:38:40 -0700 | [diff] [blame] | 682 | if (!CollectImages(FLAGS_images, &fImages)) { |
scroggo | 8673714 | 2016-02-03 12:19:11 -0800 | [diff] [blame] | 683 | exit(1); |
msarett | 95f192d | 2015-02-13 09:05:41 -0800 | [diff] [blame] | 684 | } |
mtklein | 95553d9 | 2015-03-12 08:24:21 -0700 | [diff] [blame] | 685 | |
msarett | 95f192d | 2015-02-13 09:05:41 -0800 | [diff] [blame] | 686 | // Choose the candidate color types for image decoding |
msarett | 67cb666 | 2016-06-21 08:49:26 -0700 | [diff] [blame] | 687 | fColorTypes.push_back(kN32_SkColorType); |
| 688 | if (!FLAGS_simpleCodec) { |
| 689 | fColorTypes.push_back(kRGB_565_SkColorType); |
| 690 | fColorTypes.push_back(kAlpha_8_SkColorType); |
msarett | 67cb666 | 2016-06-21 08:49:26 -0700 | [diff] [blame] | 691 | fColorTypes.push_back(kGray_8_SkColorType); |
| 692 | } |
mtklein | 9200758 | 2014-08-01 07:46:52 -0700 | [diff] [blame] | 693 | } |
| 694 | |
reed | ca2622b | 2016-03-18 07:25:55 -0700 | [diff] [blame] | 695 | static sk_sp<SkPicture> ReadPicture(const char* path) { |
mtklein | fd731ce | 2014-09-10 12:19:30 -0700 | [diff] [blame] | 696 | // Not strictly necessary, as it will be checked again later, |
| 697 | // but helps to avoid a lot of pointless work if we're going to skip it. |
Mike Klein | 88544fb | 2019-03-20 10:50:33 -0500 | [diff] [blame] | 698 | if (CommandLineFlags::ShouldSkip(FLAGS_match, SkOSPath::Basename(path).c_str())) { |
reed | ca2622b | 2016-03-18 07:25:55 -0700 | [diff] [blame] | 699 | return nullptr; |
mtklein | fd731ce | 2014-09-10 12:19:30 -0700 | [diff] [blame] | 700 | } |
| 701 | |
bungeman | f93d711 | 2016-09-16 06:24:20 -0700 | [diff] [blame] | 702 | std::unique_ptr<SkStream> stream = SkStream::MakeFromFile(path); |
| 703 | if (!stream) { |
mtklein | fd731ce | 2014-09-10 12:19:30 -0700 | [diff] [blame] | 704 | SkDebugf("Could not read %s.\n", path); |
reed | ca2622b | 2016-03-18 07:25:55 -0700 | [diff] [blame] | 705 | return nullptr; |
mtklein | fd731ce | 2014-09-10 12:19:30 -0700 | [diff] [blame] | 706 | } |
| 707 | |
reed | ca2622b | 2016-03-18 07:25:55 -0700 | [diff] [blame] | 708 | return SkPicture::MakeFromStream(stream.get()); |
mtklein | fd731ce | 2014-09-10 12:19:30 -0700 | [diff] [blame] | 709 | } |
| 710 | |
Brian Salomon | 31fddc3 | 2021-04-30 13:08:55 -0400 | [diff] [blame] | 711 | static std::unique_ptr<MSKPPlayer> ReadMSKP(const char* path) { |
| 712 | // Not strictly necessary, as it will be checked again later, |
| 713 | // but helps to avoid a lot of pointless work if we're going to skip it. |
| 714 | if (CommandLineFlags::ShouldSkip(FLAGS_match, SkOSPath::Basename(path).c_str())) { |
| 715 | return nullptr; |
| 716 | } |
| 717 | |
| 718 | std::unique_ptr<SkStreamSeekable> stream = SkStream::MakeFromFile(path); |
| 719 | if (!stream) { |
| 720 | SkDebugf("Could not read %s.\n", path); |
| 721 | return nullptr; |
| 722 | } |
| 723 | |
| 724 | return MSKPPlayer::Make(stream.get()); |
| 725 | } |
| 726 | |
fmalita | 6519c21 | 2016-09-14 08:05:17 -0700 | [diff] [blame] | 727 | static sk_sp<SkPicture> ReadSVGPicture(const char* path) { |
Mike Klein | 8ab65bf | 2020-12-04 09:20:32 -0600 | [diff] [blame] | 728 | if (CommandLineFlags::ShouldSkip(FLAGS_match, SkOSPath::Basename(path).c_str())) { |
| 729 | return nullptr; |
| 730 | } |
Brian Osman | 133823d | 2018-09-19 14:14:15 -0400 | [diff] [blame] | 731 | sk_sp<SkData> data(SkData::MakeFromFileName(path)); |
| 732 | if (!data) { |
fmalita | 6519c21 | 2016-09-14 08:05:17 -0700 | [diff] [blame] | 733 | SkDebugf("Could not read %s.\n", path); |
| 734 | return nullptr; |
| 735 | } |
| 736 | |
Hal Canary | 0f66681 | 2018-03-22 15:21:12 -0400 | [diff] [blame] | 737 | #ifdef SK_XML |
Brian Osman | 133823d | 2018-09-19 14:14:15 -0400 | [diff] [blame] | 738 | SkMemoryStream stream(std::move(data)); |
fmalita | e1baa7c | 2016-09-14 12:04:30 -0700 | [diff] [blame] | 739 | sk_sp<SkSVGDOM> svgDom = SkSVGDOM::MakeFromStream(stream); |
fmalita | 6519c21 | 2016-09-14 08:05:17 -0700 | [diff] [blame] | 740 | if (!svgDom) { |
| 741 | SkDebugf("Could not parse %s.\n", path); |
| 742 | return nullptr; |
| 743 | } |
| 744 | |
fmalita | e1baa7c | 2016-09-14 12:04:30 -0700 | [diff] [blame] | 745 | // Use the intrinsic SVG size if available, otherwise fall back to a default value. |
| 746 | static const SkSize kDefaultContainerSize = SkSize::Make(128, 128); |
| 747 | if (svgDom->containerSize().isEmpty()) { |
| 748 | svgDom->setContainerSize(kDefaultContainerSize); |
| 749 | } |
| 750 | |
fmalita | 6519c21 | 2016-09-14 08:05:17 -0700 | [diff] [blame] | 751 | SkPictureRecorder recorder; |
fmalita | e1baa7c | 2016-09-14 12:04:30 -0700 | [diff] [blame] | 752 | svgDom->render(recorder.beginRecording(svgDom->containerSize().width(), |
| 753 | svgDom->containerSize().height())); |
fmalita | 6519c21 | 2016-09-14 08:05:17 -0700 | [diff] [blame] | 754 | return recorder.finishRecordingAsPicture(); |
Hal Canary | 0f66681 | 2018-03-22 15:21:12 -0400 | [diff] [blame] | 755 | #else |
| 756 | return nullptr; |
| 757 | #endif // SK_XML |
fmalita | 6519c21 | 2016-09-14 08:05:17 -0700 | [diff] [blame] | 758 | } |
| 759 | |
mtklein | 9200758 | 2014-08-01 07:46:52 -0700 | [diff] [blame] | 760 | Benchmark* next() { |
Ben Wagner | 145dbcd | 2016-11-03 14:40:50 -0400 | [diff] [blame] | 761 | std::unique_ptr<Benchmark> bench; |
mtklein | 65dfd2f | 2016-02-03 10:40:54 -0800 | [diff] [blame] | 762 | do { |
| 763 | bench.reset(this->rawNext()); |
| 764 | if (!bench) { |
| 765 | return nullptr; |
| 766 | } |
Mike Klein | 88544fb | 2019-03-20 10:50:33 -0500 | [diff] [blame] | 767 | } while (CommandLineFlags::ShouldSkip(FLAGS_sourceType, fSourceType) || |
| 768 | CommandLineFlags::ShouldSkip(FLAGS_benchType, fBenchType)); |
mtklein | 18300a3 | 2016-03-16 13:53:35 -0700 | [diff] [blame] | 769 | return bench.release(); |
mtklein | 65dfd2f | 2016-02-03 10:40:54 -0800 | [diff] [blame] | 770 | } |
| 771 | |
| 772 | Benchmark* rawNext() { |
mtklein | e714e75 | 2014-07-31 12:13:48 -0700 | [diff] [blame] | 773 | if (fBenches) { |
Hal Canary | 972eba3 | 2018-07-30 17:07:07 -0400 | [diff] [blame] | 774 | Benchmark* bench = fBenches->get()(nullptr); |
mtklein | e714e75 | 2014-07-31 12:13:48 -0700 | [diff] [blame] | 775 | fBenches = fBenches->next(); |
mtklein | 9200758 | 2014-08-01 07:46:52 -0700 | [diff] [blame] | 776 | fSourceType = "bench"; |
mtklein | fd731ce | 2014-09-10 12:19:30 -0700 | [diff] [blame] | 777 | fBenchType = "micro"; |
mtklein | e714e75 | 2014-07-31 12:13:48 -0700 | [diff] [blame] | 778 | return bench; |
| 779 | } |
mtklein | 9200758 | 2014-08-01 07:46:52 -0700 | [diff] [blame] | 780 | |
mtklein | e714e75 | 2014-07-31 12:13:48 -0700 | [diff] [blame] | 781 | while (fGMs) { |
Ben Wagner | 406ff50 | 2019-08-12 16:39:24 -0400 | [diff] [blame] | 782 | std::unique_ptr<skiagm::GM> gm = fGMs->get()(); |
mtklein | e714e75 | 2014-07-31 12:13:48 -0700 | [diff] [blame] | 783 | fGMs = fGMs->next(); |
mtklein | cf5d9c9 | 2015-01-23 10:31:45 -0800 | [diff] [blame] | 784 | if (gm->runAsBench()) { |
mtklein | 9200758 | 2014-08-01 07:46:52 -0700 | [diff] [blame] | 785 | fSourceType = "gm"; |
mtklein | fd731ce | 2014-09-10 12:19:30 -0700 | [diff] [blame] | 786 | fBenchType = "micro"; |
Ben Wagner | 406ff50 | 2019-08-12 16:39:24 -0400 | [diff] [blame] | 787 | return new GMBench(std::move(gm)); |
mtklein | e714e75 | 2014-07-31 12:13:48 -0700 | [diff] [blame] | 788 | } |
| 789 | } |
mtklein | 9200758 | 2014-08-01 07:46:52 -0700 | [diff] [blame] | 790 | |
Hal Canary | 5dfefa2 | 2019-10-24 13:52:17 -0400 | [diff] [blame] | 791 | while (fCurrentTextBlobTrace < fTextBlobTraces.count()) { |
| 792 | SkString path = fTextBlobTraces[fCurrentTextBlobTrace++]; |
| 793 | SkString basename = SkOSPath::Basename(path.c_str()); |
| 794 | static constexpr char kEnding[] = ".trace"; |
| 795 | if (basename.endsWith(kEnding)) { |
| 796 | basename.remove(basename.size() - strlen(kEnding), strlen(kEnding)); |
| 797 | } |
| 798 | fSourceType = "texttrace"; |
| 799 | fBenchType = "micro"; |
| 800 | return CreateDiffCanvasBench( |
| 801 | SkStringPrintf("SkDiffBench-%s", basename.c_str()), |
| 802 | [path](){ return SkStream::MakeFromFile(path.c_str()); }); |
| 803 | } |
| 804 | |
mtklein | fd731ce | 2014-09-10 12:19:30 -0700 | [diff] [blame] | 805 | // First add all .skps as RecordingBenches. |
| 806 | while (fCurrentRecording < fSKPs.count()) { |
| 807 | const SkString& path = fSKPs[fCurrentRecording++]; |
reed | ca2622b | 2016-03-18 07:25:55 -0700 | [diff] [blame] | 808 | sk_sp<SkPicture> pic = ReadPicture(path.c_str()); |
| 809 | if (!pic) { |
mtklein | fd731ce | 2014-09-10 12:19:30 -0700 | [diff] [blame] | 810 | continue; |
| 811 | } |
| 812 | SkString name = SkOSPath::Basename(path.c_str()); |
| 813 | fSourceType = "skp"; |
| 814 | fBenchType = "recording"; |
Mike Klein | 88d9071 | 2018-01-27 17:30:04 +0000 | [diff] [blame] | 815 | fSKPBytes = static_cast<double>(pic->approximateBytesUsed()); |
| 816 | fSKPOps = pic->approximateOpCount(); |
Mike Klein | a705cb9 | 2019-05-14 12:33:40 -0500 | [diff] [blame] | 817 | return new RecordingBench(name.c_str(), pic.get(), FLAGS_bbh); |
mtklein | fd731ce | 2014-09-10 12:19:30 -0700 | [diff] [blame] | 818 | } |
| 819 | |
Mike Reed | e45ff46 | 2017-12-06 10:47:03 -0500 | [diff] [blame] | 820 | // Add all .skps as DeserializePictureBenchs. |
| 821 | while (fCurrentDeserialPicture < fSKPs.count()) { |
| 822 | const SkString& path = fSKPs[fCurrentDeserialPicture++]; |
| 823 | sk_sp<SkData> data = SkData::MakeFromFileName(path.c_str()); |
| 824 | if (!data) { |
| 825 | continue; |
| 826 | } |
| 827 | SkString name = SkOSPath::Basename(path.c_str()); |
| 828 | fSourceType = "skp"; |
| 829 | fBenchType = "deserial"; |
Mike Reed | 7557bbb | 2017-12-24 19:50:57 -0500 | [diff] [blame] | 830 | fSKPBytes = static_cast<double>(data->size()); |
Mike Klein | 88d9071 | 2018-01-27 17:30:04 +0000 | [diff] [blame] | 831 | fSKPOps = 0; |
Mike Reed | e45ff46 | 2017-12-06 10:47:03 -0500 | [diff] [blame] | 832 | return new DeserializePictureBench(name.c_str(), std::move(data)); |
| 833 | } |
| 834 | |
mtklein | fd731ce | 2014-09-10 12:19:30 -0700 | [diff] [blame] | 835 | // Then once each for each scale as SKPBenches (playback). |
mtklein | 9200758 | 2014-08-01 07:46:52 -0700 | [diff] [blame] | 836 | while (fCurrentScale < fScales.count()) { |
| 837 | while (fCurrentSKP < fSKPs.count()) { |
Brian Salomon | 626349b | 2020-08-27 10:54:36 -0400 | [diff] [blame] | 838 | const SkString& path = fSKPs[fCurrentSKP++]; |
reed | ca2622b | 2016-03-18 07:25:55 -0700 | [diff] [blame] | 839 | sk_sp<SkPicture> pic = ReadPicture(path.c_str()); |
| 840 | if (!pic) { |
mtklein | 9200758 | 2014-08-01 07:46:52 -0700 | [diff] [blame] | 841 | continue; |
| 842 | } |
robertphillips | 5b69377 | 2014-11-21 06:19:36 -0800 | [diff] [blame] | 843 | |
Brian Salomon | 626349b | 2020-08-27 10:54:36 -0400 | [diff] [blame] | 844 | if (FLAGS_bbh) { |
| 845 | // The SKP we read off disk doesn't have a BBH. Re-record so it grows one. |
| 846 | SkRTreeFactory factory; |
| 847 | SkPictureRecorder recorder; |
| 848 | pic->playback(recorder.beginRecording(pic->cullRect().width(), |
| 849 | pic->cullRect().height(), |
| 850 | &factory)); |
| 851 | pic = recorder.finishRecordingAsPicture(); |
mtklein | 2084050 | 2014-08-21 15:51:22 -0700 | [diff] [blame] | 852 | } |
Brian Salomon | 626349b | 2020-08-27 10:54:36 -0400 | [diff] [blame] | 853 | SkString name = SkOSPath::Basename(path.c_str()); |
| 854 | fSourceType = "skp"; |
| 855 | fBenchType = "playback"; |
| 856 | return new SKPBench(name.c_str(), pic.get(), fClip, fScales[fCurrentScale], |
| 857 | FLAGS_loopSKP); |
mtklein | 9200758 | 2014-08-01 07:46:52 -0700 | [diff] [blame] | 858 | } |
fmalita | 6519c21 | 2016-09-14 08:05:17 -0700 | [diff] [blame] | 859 | |
Brian Salomon | 626349b | 2020-08-27 10:54:36 -0400 | [diff] [blame] | 860 | while (fCurrentSVG < fSVGs.count()) { |
| 861 | const char* path = fSVGs[fCurrentSVG++].c_str(); |
fmalita | 6519c21 | 2016-09-14 08:05:17 -0700 | [diff] [blame] | 862 | if (sk_sp<SkPicture> pic = ReadSVGPicture(path)) { |
| 863 | fSourceType = "svg"; |
| 864 | fBenchType = "playback"; |
| 865 | return new SKPBench(SkOSPath::Basename(path).c_str(), pic.get(), fClip, |
Brian Salomon | 626349b | 2020-08-27 10:54:36 -0400 | [diff] [blame] | 866 | fScales[fCurrentScale], FLAGS_loopSKP); |
fmalita | 6519c21 | 2016-09-14 08:05:17 -0700 | [diff] [blame] | 867 | } |
| 868 | } |
| 869 | |
mtklein | 9200758 | 2014-08-01 07:46:52 -0700 | [diff] [blame] | 870 | fCurrentSKP = 0; |
fmalita | 6519c21 | 2016-09-14 08:05:17 -0700 | [diff] [blame] | 871 | fCurrentSVG = 0; |
mtklein | 9200758 | 2014-08-01 07:46:52 -0700 | [diff] [blame] | 872 | fCurrentScale++; |
| 873 | } |
| 874 | |
joshualitt | 261c3ad | 2015-04-27 09:16:57 -0700 | [diff] [blame] | 875 | // Now loop over each skp again if we have an animation |
cdalton | 63a8285 | 2015-06-29 14:06:10 -0700 | [diff] [blame] | 876 | if (fZoomMax != 1.0f && fZoomPeriodMs > 0) { |
joshualitt | 261c3ad | 2015-04-27 09:16:57 -0700 | [diff] [blame] | 877 | while (fCurrentAnimSKP < fSKPs.count()) { |
| 878 | const SkString& path = fSKPs[fCurrentAnimSKP]; |
reed | ca2622b | 2016-03-18 07:25:55 -0700 | [diff] [blame] | 879 | sk_sp<SkPicture> pic = ReadPicture(path.c_str()); |
| 880 | if (!pic) { |
joshualitt | 261c3ad | 2015-04-27 09:16:57 -0700 | [diff] [blame] | 881 | fCurrentAnimSKP++; |
| 882 | continue; |
| 883 | } |
| 884 | |
| 885 | fCurrentAnimSKP++; |
| 886 | SkString name = SkOSPath::Basename(path.c_str()); |
Ben Wagner | acf98df | 2019-07-12 12:51:44 -0400 | [diff] [blame] | 887 | sk_sp<SKPAnimationBench::Animation> animation = |
| 888 | SKPAnimationBench::MakeZoomAnimation(fZoomMax, fZoomPeriodMs); |
| 889 | return new SKPAnimationBench(name.c_str(), pic.get(), fClip, std::move(animation), |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 890 | FLAGS_loopSKP); |
joshualitt | 261c3ad | 2015-04-27 09:16:57 -0700 | [diff] [blame] | 891 | } |
| 892 | } |
| 893 | |
Brian Salomon | 31fddc3 | 2021-04-30 13:08:55 -0400 | [diff] [blame] | 894 | // Read all MSKPs as benches |
| 895 | while (fCurrentMSKP < fMSKPs.count()) { |
| 896 | const SkString& path = fMSKPs[fCurrentMSKP++]; |
| 897 | std::unique_ptr<MSKPPlayer> player = ReadMSKP(path.c_str()); |
| 898 | if (!player) { |
| 899 | continue; |
| 900 | } |
| 901 | SkString name = SkOSPath::Basename(path.c_str()); |
| 902 | fSourceType = "mskp"; |
| 903 | fBenchType = "mskp"; |
| 904 | return new MSKPBench(std::move(name), std::move(player)); |
| 905 | } |
| 906 | |
scroggo | 60869a4 | 2015-04-01 12:09:17 -0700 | [diff] [blame] | 907 | for (; fCurrentCodec < fImages.count(); fCurrentCodec++) { |
scroggo | 303fa35 | 2015-10-05 11:03:34 -0700 | [diff] [blame] | 908 | fSourceType = "image"; |
| 909 | fBenchType = "skcodec"; |
scroggo | 60869a4 | 2015-04-01 12:09:17 -0700 | [diff] [blame] | 910 | const SkString& path = fImages[fCurrentCodec]; |
Mike Klein | 88544fb | 2019-03-20 10:50:33 -0500 | [diff] [blame] | 911 | if (CommandLineFlags::ShouldSkip(FLAGS_match, path.c_str())) { |
mtklein | 6f0ff91 | 2016-01-11 09:04:21 -0800 | [diff] [blame] | 912 | continue; |
| 913 | } |
bungeman | 38d909e | 2016-08-02 14:40:46 -0700 | [diff] [blame] | 914 | sk_sp<SkData> encoded(SkData::MakeFromFileName(path.c_str())); |
Mike Reed | ede7bac | 2017-07-23 15:30:02 -0400 | [diff] [blame] | 915 | std::unique_ptr<SkCodec> codec(SkCodec::MakeFromData(encoded)); |
scroggo | 60869a4 | 2015-04-01 12:09:17 -0700 | [diff] [blame] | 916 | if (!codec) { |
| 917 | // Nothing to time. |
msarett | 9d9725c | 2015-04-24 11:41:55 -0700 | [diff] [blame] | 918 | SkDebugf("Cannot find codec for %s\n", path.c_str()); |
scroggo | 60869a4 | 2015-04-01 12:09:17 -0700 | [diff] [blame] | 919 | continue; |
| 920 | } |
scroggo | 2102799 | 2015-04-02 13:22:38 -0700 | [diff] [blame] | 921 | |
scroggo | 60869a4 | 2015-04-01 12:09:17 -0700 | [diff] [blame] | 922 | while (fCurrentColorType < fColorTypes.count()) { |
scroggo | 2102799 | 2015-04-02 13:22:38 -0700 | [diff] [blame] | 923 | const SkColorType colorType = fColorTypes[fCurrentColorType]; |
scroggo | 2102799 | 2015-04-02 13:22:38 -0700 | [diff] [blame] | 924 | |
msarett | c7796b9 | 2016-01-07 14:20:20 -0800 | [diff] [blame] | 925 | SkAlphaType alphaType = codec->getInfo().alphaType(); |
msarett | 67cb666 | 2016-06-21 08:49:26 -0700 | [diff] [blame] | 926 | if (FLAGS_simpleCodec) { |
| 927 | if (kUnpremul_SkAlphaType == alphaType) { |
| 928 | alphaType = kPremul_SkAlphaType; |
| 929 | } |
| 930 | |
| 931 | fCurrentColorType++; |
| 932 | } else { |
| 933 | switch (alphaType) { |
| 934 | case kOpaque_SkAlphaType: |
| 935 | // We only need to test one alpha type (opaque). |
msarett | c7796b9 | 2016-01-07 14:20:20 -0800 | [diff] [blame] | 936 | fCurrentColorType++; |
msarett | 67cb666 | 2016-06-21 08:49:26 -0700 | [diff] [blame] | 937 | break; |
| 938 | case kUnpremul_SkAlphaType: |
| 939 | case kPremul_SkAlphaType: |
| 940 | if (0 == fCurrentAlphaType) { |
| 941 | // Test unpremul first. |
| 942 | alphaType = kUnpremul_SkAlphaType; |
| 943 | fCurrentAlphaType++; |
| 944 | } else { |
| 945 | // Test premul. |
| 946 | alphaType = kPremul_SkAlphaType; |
| 947 | fCurrentAlphaType = 0; |
| 948 | fCurrentColorType++; |
| 949 | } |
| 950 | break; |
| 951 | default: |
| 952 | SkASSERT(false); |
| 953 | fCurrentColorType++; |
| 954 | break; |
| 955 | } |
scroggo | 2102799 | 2015-04-02 13:22:38 -0700 | [diff] [blame] | 956 | } |
| 957 | |
msarett | c7796b9 | 2016-01-07 14:20:20 -0800 | [diff] [blame] | 958 | // Make sure we can decode to this color type and alpha type. |
| 959 | SkImageInfo info = |
| 960 | codec->getInfo().makeColorType(colorType).makeAlphaType(alphaType); |
scroggo | 2102799 | 2015-04-02 13:22:38 -0700 | [diff] [blame] | 961 | const size_t rowBytes = info.minRowBytes(); |
Mike Reed | f0ffb89 | 2017-10-03 14:47:21 -0400 | [diff] [blame] | 962 | SkAutoMalloc storage(info.computeByteSize(rowBytes)); |
scroggo | 2102799 | 2015-04-02 13:22:38 -0700 | [diff] [blame] | 963 | |
scroggo | eb602a5 | 2015-07-09 08:16:03 -0700 | [diff] [blame] | 964 | const SkCodec::Result result = codec->getPixels( |
Leon Scroggins | 571b30f | 2017-07-11 17:35:31 +0000 | [diff] [blame] | 965 | info, storage.get(), rowBytes); |
scroggo | 60869a4 | 2015-04-01 12:09:17 -0700 | [diff] [blame] | 966 | switch (result) { |
scroggo | eb602a5 | 2015-07-09 08:16:03 -0700 | [diff] [blame] | 967 | case SkCodec::kSuccess: |
| 968 | case SkCodec::kIncompleteInput: |
scroggo | 60869a4 | 2015-04-01 12:09:17 -0700 | [diff] [blame] | 969 | return new CodecBench(SkOSPath::Basename(path.c_str()), |
bungeman | 38d909e | 2016-08-02 14:40:46 -0700 | [diff] [blame] | 970 | encoded.get(), colorType, alphaType); |
scroggo | eb602a5 | 2015-07-09 08:16:03 -0700 | [diff] [blame] | 971 | case SkCodec::kInvalidConversion: |
scroggo | 60869a4 | 2015-04-01 12:09:17 -0700 | [diff] [blame] | 972 | // This is okay. Not all conversions are valid. |
| 973 | break; |
scroggo | 60869a4 | 2015-04-01 12:09:17 -0700 | [diff] [blame] | 974 | default: |
| 975 | // This represents some sort of failure. |
| 976 | SkASSERT(false); |
| 977 | break; |
| 978 | } |
| 979 | } |
| 980 | fCurrentColorType = 0; |
| 981 | } |
| 982 | |
msarett | 8445102 | 2016-02-11 06:45:51 -0800 | [diff] [blame] | 983 | // Run AndroidCodecBenches |
| 984 | const int sampleSizes[] = { 2, 4, 8 }; |
| 985 | for (; fCurrentAndroidCodec < fImages.count(); fCurrentAndroidCodec++) { |
| 986 | fSourceType = "image"; |
| 987 | fBenchType = "skandroidcodec"; |
| 988 | |
| 989 | const SkString& path = fImages[fCurrentAndroidCodec]; |
Mike Klein | 88544fb | 2019-03-20 10:50:33 -0500 | [diff] [blame] | 990 | if (CommandLineFlags::ShouldSkip(FLAGS_match, path.c_str())) { |
msarett | 8445102 | 2016-02-11 06:45:51 -0800 | [diff] [blame] | 991 | continue; |
| 992 | } |
bungeman | 38d909e | 2016-08-02 14:40:46 -0700 | [diff] [blame] | 993 | sk_sp<SkData> encoded(SkData::MakeFromFileName(path.c_str())); |
Mike Reed | ede7bac | 2017-07-23 15:30:02 -0400 | [diff] [blame] | 994 | std::unique_ptr<SkAndroidCodec> codec(SkAndroidCodec::MakeFromData(encoded)); |
msarett | 8445102 | 2016-02-11 06:45:51 -0800 | [diff] [blame] | 995 | if (!codec) { |
| 996 | // Nothing to time. |
| 997 | SkDebugf("Cannot find codec for %s\n", path.c_str()); |
| 998 | continue; |
| 999 | } |
| 1000 | |
| 1001 | while (fCurrentSampleSize < (int) SK_ARRAY_COUNT(sampleSizes)) { |
| 1002 | int sampleSize = sampleSizes[fCurrentSampleSize]; |
| 1003 | fCurrentSampleSize++; |
Brian Osman | 788b916 | 2020-02-07 10:36:46 -0500 | [diff] [blame] | 1004 | if (10 * sampleSize > std::min(codec->getInfo().width(), codec->getInfo().height())) { |
msarett | 8445102 | 2016-02-11 06:45:51 -0800 | [diff] [blame] | 1005 | // Avoid benchmarking scaled decodes of already small images. |
| 1006 | break; |
| 1007 | } |
| 1008 | |
bungeman | 38d909e | 2016-08-02 14:40:46 -0700 | [diff] [blame] | 1009 | return new AndroidCodecBench(SkOSPath::Basename(path.c_str()), |
| 1010 | encoded.get(), sampleSize); |
msarett | 8445102 | 2016-02-11 06:45:51 -0800 | [diff] [blame] | 1011 | } |
| 1012 | fCurrentSampleSize = 0; |
| 1013 | } |
| 1014 | |
Leon Scroggins III | 87caae6 | 2020-05-04 10:02:45 -0400 | [diff] [blame] | 1015 | #ifdef SK_ENABLE_ANDROID_UTILS |
msarett | 7f69144 | 2015-09-22 11:56:16 -0700 | [diff] [blame] | 1016 | // Run the BRDBenches |
msarett | 7f69144 | 2015-09-22 11:56:16 -0700 | [diff] [blame] | 1017 | // We intend to create benchmarks that model the use cases in |
| 1018 | // android/libraries/social/tiledimage. In this library, an image is decoded in 512x512 |
| 1019 | // tiles. The image can be translated freely, so the location of a tile may be anywhere in |
| 1020 | // the image. For that reason, we will benchmark decodes in five representative locations |
| 1021 | // in the image. Additionally, this use case utilizes power of two scaling, so we will |
| 1022 | // test on power of two sample sizes. The output tile is always 512x512, so, when a |
| 1023 | // sampleSize is used, the size of the subset that is decoded is always |
| 1024 | // (sampleSize*512)x(sampleSize*512). |
| 1025 | // There are a few good reasons to only test on power of two sample sizes at this time: |
msarett | 7f69144 | 2015-09-22 11:56:16 -0700 | [diff] [blame] | 1026 | // All use cases we are aware of only scale by powers of two. |
| 1027 | // PNG decodes use the indicated sampling strategy regardless of the sample size, so |
| 1028 | // these tests are sufficient to provide good coverage of our scaling options. |
msarett | 8445102 | 2016-02-11 06:45:51 -0800 | [diff] [blame] | 1029 | const uint32_t brdSampleSizes[] = { 1, 2, 4, 8, 16 }; |
msarett | 7f69144 | 2015-09-22 11:56:16 -0700 | [diff] [blame] | 1030 | const uint32_t minOutputSize = 512; |
mtklein | 6f0ff91 | 2016-01-11 09:04:21 -0800 | [diff] [blame] | 1031 | for (; fCurrentBRDImage < fImages.count(); fCurrentBRDImage++) { |
msarett | d1227a7 | 2016-05-18 06:23:57 -0700 | [diff] [blame] | 1032 | fSourceType = "image"; |
| 1033 | fBenchType = "BRD"; |
| 1034 | |
mtklein | 6f0ff91 | 2016-01-11 09:04:21 -0800 | [diff] [blame] | 1035 | const SkString& path = fImages[fCurrentBRDImage]; |
Mike Klein | 88544fb | 2019-03-20 10:50:33 -0500 | [diff] [blame] | 1036 | if (CommandLineFlags::ShouldSkip(FLAGS_match, path.c_str())) { |
mtklein | 6f0ff91 | 2016-01-11 09:04:21 -0800 | [diff] [blame] | 1037 | continue; |
| 1038 | } |
scroggo | 860e8a6 | 2015-10-15 07:51:28 -0700 | [diff] [blame] | 1039 | |
msarett | d1227a7 | 2016-05-18 06:23:57 -0700 | [diff] [blame] | 1040 | while (fCurrentColorType < fColorTypes.count()) { |
| 1041 | while (fCurrentSampleSize < (int) SK_ARRAY_COUNT(brdSampleSizes)) { |
| 1042 | while (fCurrentSubsetType <= kLastSingle_SubsetType) { |
scroggo | 860e8a6 | 2015-10-15 07:51:28 -0700 | [diff] [blame] | 1043 | |
bungeman | 38d909e | 2016-08-02 14:40:46 -0700 | [diff] [blame] | 1044 | sk_sp<SkData> encoded(SkData::MakeFromFileName(path.c_str())); |
msarett | d1227a7 | 2016-05-18 06:23:57 -0700 | [diff] [blame] | 1045 | const SkColorType colorType = fColorTypes[fCurrentColorType]; |
| 1046 | uint32_t sampleSize = brdSampleSizes[fCurrentSampleSize]; |
| 1047 | int currentSubsetType = fCurrentSubsetType++; |
scroggo | 860e8a6 | 2015-10-15 07:51:28 -0700 | [diff] [blame] | 1048 | |
msarett | d1227a7 | 2016-05-18 06:23:57 -0700 | [diff] [blame] | 1049 | int width = 0; |
| 1050 | int height = 0; |
reed | 42943c8 | 2016-09-12 12:01:44 -0700 | [diff] [blame] | 1051 | if (!valid_brd_bench(encoded, colorType, sampleSize, minOutputSize, |
msarett | d1227a7 | 2016-05-18 06:23:57 -0700 | [diff] [blame] | 1052 | &width, &height)) { |
| 1053 | break; |
msarett | 7f69144 | 2015-09-22 11:56:16 -0700 | [diff] [blame] | 1054 | } |
msarett | d1227a7 | 2016-05-18 06:23:57 -0700 | [diff] [blame] | 1055 | |
| 1056 | SkString basename = SkOSPath::Basename(path.c_str()); |
| 1057 | SkIRect subset; |
| 1058 | const uint32_t subsetSize = sampleSize * minOutputSize; |
| 1059 | switch (currentSubsetType) { |
| 1060 | case kTopLeft_SubsetType: |
| 1061 | basename.append("_TopLeft"); |
| 1062 | subset = SkIRect::MakeXYWH(0, 0, subsetSize, subsetSize); |
| 1063 | break; |
| 1064 | case kTopRight_SubsetType: |
| 1065 | basename.append("_TopRight"); |
| 1066 | subset = SkIRect::MakeXYWH(width - subsetSize, 0, subsetSize, |
| 1067 | subsetSize); |
| 1068 | break; |
| 1069 | case kMiddle_SubsetType: |
| 1070 | basename.append("_Middle"); |
| 1071 | subset = SkIRect::MakeXYWH((width - subsetSize) / 2, |
| 1072 | (height - subsetSize) / 2, subsetSize, subsetSize); |
| 1073 | break; |
| 1074 | case kBottomLeft_SubsetType: |
| 1075 | basename.append("_BottomLeft"); |
| 1076 | subset = SkIRect::MakeXYWH(0, height - subsetSize, subsetSize, |
| 1077 | subsetSize); |
| 1078 | break; |
| 1079 | case kBottomRight_SubsetType: |
| 1080 | basename.append("_BottomRight"); |
| 1081 | subset = SkIRect::MakeXYWH(width - subsetSize, |
| 1082 | height - subsetSize, subsetSize, subsetSize); |
| 1083 | break; |
| 1084 | default: |
| 1085 | SkASSERT(false); |
| 1086 | } |
| 1087 | |
| 1088 | return new BitmapRegionDecoderBench(basename.c_str(), encoded.get(), |
| 1089 | colorType, sampleSize, subset); |
msarett | 7f69144 | 2015-09-22 11:56:16 -0700 | [diff] [blame] | 1090 | } |
msarett | d1227a7 | 2016-05-18 06:23:57 -0700 | [diff] [blame] | 1091 | fCurrentSubsetType = 0; |
| 1092 | fCurrentSampleSize++; |
msarett | 7f69144 | 2015-09-22 11:56:16 -0700 | [diff] [blame] | 1093 | } |
msarett | d1227a7 | 2016-05-18 06:23:57 -0700 | [diff] [blame] | 1094 | fCurrentSampleSize = 0; |
| 1095 | fCurrentColorType++; |
msarett | 7f69144 | 2015-09-22 11:56:16 -0700 | [diff] [blame] | 1096 | } |
msarett | d1227a7 | 2016-05-18 06:23:57 -0700 | [diff] [blame] | 1097 | fCurrentColorType = 0; |
msarett | 7f69144 | 2015-09-22 11:56:16 -0700 | [diff] [blame] | 1098 | } |
Leon Scroggins III | 87caae6 | 2020-05-04 10:02:45 -0400 | [diff] [blame] | 1099 | #endif // SK_ENABLE_ANDROID_UTILS |
msarett | 7f69144 | 2015-09-22 11:56:16 -0700 | [diff] [blame] | 1100 | |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 1101 | return nullptr; |
mtklein | e714e75 | 2014-07-31 12:13:48 -0700 | [diff] [blame] | 1102 | } |
mtklein | 9200758 | 2014-08-01 07:46:52 -0700 | [diff] [blame] | 1103 | |
Brian Osman | 8c0a1ca | 2019-01-28 14:24:29 -0500 | [diff] [blame] | 1104 | void fillCurrentOptions(NanoJSONResultsWriter& log) const { |
| 1105 | log.appendString("source_type", fSourceType); |
| 1106 | log.appendString("bench_type", fBenchType); |
mtklein | 9200758 | 2014-08-01 07:46:52 -0700 | [diff] [blame] | 1107 | if (0 == strcmp(fSourceType, "skp")) { |
Brian Osman | 8c0a1ca | 2019-01-28 14:24:29 -0500 | [diff] [blame] | 1108 | log.appendString("clip", |
mtklein | 9200758 | 2014-08-01 07:46:52 -0700 | [diff] [blame] | 1109 | SkStringPrintf("%d %d %d %d", fClip.fLeft, fClip.fTop, |
| 1110 | fClip.fRight, fClip.fBottom).c_str()); |
djsollen | f2b340f | 2016-01-29 08:51:04 -0800 | [diff] [blame] | 1111 | SkASSERT_RELEASE(fCurrentScale < fScales.count()); // debugging paranoia |
Brian Osman | 8c0a1ca | 2019-01-28 14:24:29 -0500 | [diff] [blame] | 1112 | log.appendString("scale", SkStringPrintf("%.2g", fScales[fCurrentScale]).c_str()); |
mtklein | 9200758 | 2014-08-01 07:46:52 -0700 | [diff] [blame] | 1113 | } |
Brian Osman | 8c0a1ca | 2019-01-28 14:24:29 -0500 | [diff] [blame] | 1114 | } |
| 1115 | |
| 1116 | void fillCurrentMetrics(NanoJSONResultsWriter& log) const { |
mtklein | 051e56d | 2014-12-04 08:46:51 -0800 | [diff] [blame] | 1117 | if (0 == strcmp(fBenchType, "recording")) { |
Brian Osman | 8c0a1ca | 2019-01-28 14:24:29 -0500 | [diff] [blame] | 1118 | log.appendMetric("bytes", fSKPBytes); |
| 1119 | log.appendMetric("ops", fSKPOps); |
mtklein | 051e56d | 2014-12-04 08:46:51 -0800 | [diff] [blame] | 1120 | } |
mtklein | 9200758 | 2014-08-01 07:46:52 -0700 | [diff] [blame] | 1121 | } |
| 1122 | |
mtklein | e714e75 | 2014-07-31 12:13:48 -0700 | [diff] [blame] | 1123 | private: |
Leon Scroggins III | 87caae6 | 2020-05-04 10:02:45 -0400 | [diff] [blame] | 1124 | #ifdef SK_ENABLE_ANDROID_UTILS |
msarett | b23e6aa | 2015-06-09 13:56:10 -0700 | [diff] [blame] | 1125 | enum SubsetType { |
| 1126 | kTopLeft_SubsetType = 0, |
| 1127 | kTopRight_SubsetType = 1, |
msarett | ab80e35 | 2015-06-17 10:28:22 -0700 | [diff] [blame] | 1128 | kMiddle_SubsetType = 2, |
| 1129 | kBottomLeft_SubsetType = 3, |
| 1130 | kBottomRight_SubsetType = 4, |
| 1131 | kTranslate_SubsetType = 5, |
| 1132 | kZoom_SubsetType = 6, |
msarett | 7f69144 | 2015-09-22 11:56:16 -0700 | [diff] [blame] | 1133 | kLast_SubsetType = kZoom_SubsetType, |
| 1134 | kLastSingle_SubsetType = kBottomRight_SubsetType, |
msarett | b23e6aa | 2015-06-09 13:56:10 -0700 | [diff] [blame] | 1135 | }; |
Leon Scroggins III | 87caae6 | 2020-05-04 10:02:45 -0400 | [diff] [blame] | 1136 | #endif |
msarett | b23e6aa | 2015-06-09 13:56:10 -0700 | [diff] [blame] | 1137 | |
mtklein | e714e75 | 2014-07-31 12:13:48 -0700 | [diff] [blame] | 1138 | const BenchRegistry* fBenches; |
| 1139 | const skiagm::GMRegistry* fGMs; |
mtklein | 9200758 | 2014-08-01 07:46:52 -0700 | [diff] [blame] | 1140 | SkIRect fClip; |
| 1141 | SkTArray<SkScalar> fScales; |
| 1142 | SkTArray<SkString> fSKPs; |
Brian Salomon | 31fddc3 | 2021-04-30 13:08:55 -0400 | [diff] [blame] | 1143 | SkTArray<SkString> fMSKPs; |
fmalita | 6519c21 | 2016-09-14 08:05:17 -0700 | [diff] [blame] | 1144 | SkTArray<SkString> fSVGs; |
Hal Canary | 5dfefa2 | 2019-10-24 13:52:17 -0400 | [diff] [blame] | 1145 | SkTArray<SkString> fTextBlobTraces; |
msarett | 95f192d | 2015-02-13 09:05:41 -0800 | [diff] [blame] | 1146 | SkTArray<SkString> fImages; |
msarett | 74deb98 | 2015-10-20 16:45:56 -0700 | [diff] [blame] | 1147 | SkTArray<SkColorType, true> fColorTypes; |
cdalton | 63a8285 | 2015-06-29 14:06:10 -0700 | [diff] [blame] | 1148 | SkScalar fZoomMax; |
| 1149 | double fZoomPeriodMs; |
mtklein | 9200758 | 2014-08-01 07:46:52 -0700 | [diff] [blame] | 1150 | |
Mike Klein | 88d9071 | 2018-01-27 17:30:04 +0000 | [diff] [blame] | 1151 | double fSKPBytes, fSKPOps; |
mtklein | 051e56d | 2014-12-04 08:46:51 -0800 | [diff] [blame] | 1152 | |
mtklein | fd731ce | 2014-09-10 12:19:30 -0700 | [diff] [blame] | 1153 | const char* fSourceType; // What we're benching: bench, GM, SKP, ... |
| 1154 | const char* fBenchType; // How we bench it: micro, recording, playback, ... |
Hal Canary | 2362ae7 | 2019-10-24 13:40:40 -0400 | [diff] [blame] | 1155 | int fCurrentRecording = 0; |
| 1156 | int fCurrentDeserialPicture = 0; |
Brian Salomon | 31fddc3 | 2021-04-30 13:08:55 -0400 | [diff] [blame] | 1157 | int fCurrentMSKP = 0; |
Hal Canary | 2362ae7 | 2019-10-24 13:40:40 -0400 | [diff] [blame] | 1158 | int fCurrentScale = 0; |
| 1159 | int fCurrentSKP = 0; |
| 1160 | int fCurrentSVG = 0; |
Hal Canary | 5dfefa2 | 2019-10-24 13:52:17 -0400 | [diff] [blame] | 1161 | int fCurrentTextBlobTrace = 0; |
Hal Canary | 2362ae7 | 2019-10-24 13:40:40 -0400 | [diff] [blame] | 1162 | int fCurrentCodec = 0; |
| 1163 | int fCurrentAndroidCodec = 0; |
Leon Scroggins III | 87caae6 | 2020-05-04 10:02:45 -0400 | [diff] [blame] | 1164 | #ifdef SK_ENABLE_ANDROID_UTILS |
Hal Canary | 2362ae7 | 2019-10-24 13:40:40 -0400 | [diff] [blame] | 1165 | int fCurrentBRDImage = 0; |
Leon Scroggins III | 87caae6 | 2020-05-04 10:02:45 -0400 | [diff] [blame] | 1166 | int fCurrentSubsetType = 0; |
| 1167 | #endif |
Hal Canary | 2362ae7 | 2019-10-24 13:40:40 -0400 | [diff] [blame] | 1168 | int fCurrentColorType = 0; |
| 1169 | int fCurrentAlphaType = 0; |
Hal Canary | 2362ae7 | 2019-10-24 13:40:40 -0400 | [diff] [blame] | 1170 | int fCurrentSampleSize = 0; |
| 1171 | int fCurrentAnimSKP = 0; |
mtklein | e714e75 | 2014-07-31 12:13:48 -0700 | [diff] [blame] | 1172 | }; |
| 1173 | |
msarett | c149f0e | 2016-01-04 11:35:43 -0800 | [diff] [blame] | 1174 | // Some runs (mostly, Valgrind) are so slow that the bot framework thinks we've hung. |
| 1175 | // This prints something every once in a while so that it knows we're still working. |
| 1176 | static void start_keepalive() { |
Mike Klein | 03141d2 | 2017-10-30 11:57:15 -0400 | [diff] [blame] | 1177 | static std::thread* intentionallyLeaked = new std::thread([]{ |
| 1178 | for (;;) { |
| 1179 | static const int kSec = 1200; |
| 1180 | #if defined(SK_BUILD_FOR_WIN) |
| 1181 | Sleep(kSec * 1000); |
| 1182 | #else |
| 1183 | sleep(kSec); |
| 1184 | #endif |
| 1185 | SkDebugf("\nBenchmarks still running...\n"); |
msarett | c149f0e | 2016-01-04 11:35:43 -0800 | [diff] [blame] | 1186 | } |
Mike Klein | 03141d2 | 2017-10-30 11:57:15 -0400 | [diff] [blame] | 1187 | }); |
| 1188 | (void)intentionallyLeaked; |
msarett | c149f0e | 2016-01-04 11:35:43 -0800 | [diff] [blame] | 1189 | } |
| 1190 | |
John Stiles | 2ef627a | 2021-03-23 10:25:02 -0400 | [diff] [blame] | 1191 | class NanobenchShaderErrorHandler : public GrContextOptions::ShaderErrorHandler { |
| 1192 | void compileError(const char* shader, const char* errors) override { |
| 1193 | // Nanobench should abort if any shader can't compile. Failure is much better than |
| 1194 | // reporting meaningless performance metrics. |
| 1195 | SkSL::String message = GrShaderUtils::BuildShaderErrorMessage(shader, errors); |
John Stiles | 345f140 | 2021-03-23 10:25:15 -0400 | [diff] [blame] | 1196 | SK_ABORT("\n%s", message.c_str()); |
John Stiles | 2ef627a | 2021-03-23 10:25:02 -0400 | [diff] [blame] | 1197 | } |
| 1198 | }; |
| 1199 | |
Mike Klein | be28ee2 | 2017-02-06 12:46:20 -0500 | [diff] [blame] | 1200 | int main(int argc, char** argv) { |
Mike Klein | 88544fb | 2019-03-20 10:50:33 -0500 | [diff] [blame] | 1201 | CommandLineFlags::Parse(argc, argv); |
Brian Osman | 53136aa | 2017-07-20 15:43:35 -0400 | [diff] [blame] | 1202 | |
Brian Osman | bc8150f | 2017-07-24 11:38:01 -0400 | [diff] [blame] | 1203 | initializeEventTracingForTools(); |
Brian Osman | 53136aa | 2017-07-20 15:43:35 -0400 | [diff] [blame] | 1204 | |
Mike Klein | adacaef | 2017-02-06 09:26:14 -0500 | [diff] [blame] | 1205 | #if defined(SK_BUILD_FOR_IOS) |
| 1206 | cd_Documents(); |
| 1207 | #endif |
jcgregorio | 3b27ade | 2014-11-13 08:06:40 -0800 | [diff] [blame] | 1208 | SetupCrashHandler(); |
mtklein | f372321 | 2014-06-25 14:08:00 -0700 | [diff] [blame] | 1209 | SkAutoGraphics ag; |
mtklein | cc29d26 | 2015-07-09 10:04:56 -0700 | [diff] [blame] | 1210 | SkTaskGroup::Enabler enabled(FLAGS_threads); |
mtklein | f372321 | 2014-06-25 14:08:00 -0700 | [diff] [blame] | 1211 | |
Chris Dalton | 040238b | 2017-12-18 14:22:34 -0700 | [diff] [blame] | 1212 | SetCtxOptionsFromCommonFlags(&grContextOpts); |
krajcevski | 69a5560 | 2014-08-13 10:46:31 -0700 | [diff] [blame] | 1213 | |
John Stiles | 2ef627a | 2021-03-23 10:25:02 -0400 | [diff] [blame] | 1214 | NanobenchShaderErrorHandler errorHandler; |
| 1215 | grContextOpts.fShaderErrorHandler = &errorHandler; |
| 1216 | |
bsalomon | 6eb03cc | 2014-08-07 14:28:50 -0700 | [diff] [blame] | 1217 | if (kAutoTuneLoops != FLAGS_loops) { |
mtklein | a189ccd | 2014-07-14 12:28:47 -0700 | [diff] [blame] | 1218 | FLAGS_samples = 1; |
| 1219 | FLAGS_gpuFrameLag = 0; |
| 1220 | } |
| 1221 | |
bsalomon | 6eb03cc | 2014-08-07 14:28:50 -0700 | [diff] [blame] | 1222 | if (!FLAGS_writePath.isEmpty()) { |
| 1223 | SkDebugf("Writing files to %s.\n", FLAGS_writePath[0]); |
| 1224 | if (!sk_mkdir(FLAGS_writePath[0])) { |
| 1225 | SkDebugf("Could not create %s. Files won't be written.\n", FLAGS_writePath[0]); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 1226 | FLAGS_writePath.set(0, nullptr); |
bsalomon | 6eb03cc | 2014-08-07 14:28:50 -0700 | [diff] [blame] | 1227 | } |
| 1228 | } |
| 1229 | |
Brian Osman | 8c0a1ca | 2019-01-28 14:24:29 -0500 | [diff] [blame] | 1230 | std::unique_ptr<SkWStream> logStream(new SkNullWStream); |
mtklein | 60317d0f | 2014-07-14 11:30:37 -0700 | [diff] [blame] | 1231 | if (!FLAGS_outResultsFile.isEmpty()) { |
mtklein | 5352015 | 2016-01-20 09:53:59 -0800 | [diff] [blame] | 1232 | #if defined(SK_RELEASE) |
Herb Derby | efe9df3 | 2021-06-18 20:31:43 +0000 | [diff] [blame] | 1233 | logStream.reset(new SkFILEWStream(FLAGS_outResultsFile[0])); |
mtklein | 5352015 | 2016-01-20 09:53:59 -0800 | [diff] [blame] | 1234 | #else |
| 1235 | SkDebugf("I'm ignoring --outResultsFile because this is a Debug build."); |
| 1236 | return 1; |
| 1237 | #endif |
mtklein | 60317d0f | 2014-07-14 11:30:37 -0700 | [diff] [blame] | 1238 | } |
Brian Osman | 8c0a1ca | 2019-01-28 14:24:29 -0500 | [diff] [blame] | 1239 | NanoJSONResultsWriter log(logStream.get(), SkJSONWriter::Mode::kPretty); |
| 1240 | log.beginObject(); // root |
mtklein | 1915b62 | 2014-08-20 11:45:00 -0700 | [diff] [blame] | 1241 | |
| 1242 | if (1 == FLAGS_properties.count() % 2) { |
| 1243 | SkDebugf("ERROR: --properties must be passed with an even number of arguments.\n"); |
| 1244 | return 1; |
| 1245 | } |
| 1246 | for (int i = 1; i < FLAGS_properties.count(); i += 2) { |
Brian Osman | 8c0a1ca | 2019-01-28 14:24:29 -0500 | [diff] [blame] | 1247 | log.appendString(FLAGS_properties[i-1], FLAGS_properties[i]); |
mtklein | 1915b62 | 2014-08-20 11:45:00 -0700 | [diff] [blame] | 1248 | } |
jcgregorio | bf5e523 | 2014-07-17 13:14:16 -0700 | [diff] [blame] | 1249 | |
| 1250 | if (1 == FLAGS_key.count() % 2) { |
| 1251 | SkDebugf("ERROR: --key must be passed with an even number of arguments.\n"); |
| 1252 | return 1; |
| 1253 | } |
Brian Osman | 8c0a1ca | 2019-01-28 14:24:29 -0500 | [diff] [blame] | 1254 | if (FLAGS_key.count()) { |
| 1255 | log.beginObject("key"); |
| 1256 | for (int i = 1; i < FLAGS_key.count(); i += 2) { |
| 1257 | log.appendString(FLAGS_key[i - 1], FLAGS_key[i]); |
| 1258 | } |
| 1259 | log.endObject(); // key |
mtklein | 94e5156 | 2014-08-19 12:41:53 -0700 | [diff] [blame] | 1260 | } |
mtklein | 60317d0f | 2014-07-14 11:30:37 -0700 | [diff] [blame] | 1261 | |
mtklein | f372321 | 2014-06-25 14:08:00 -0700 | [diff] [blame] | 1262 | const double overhead = estimate_timer_overhead(); |
mtklein | 55b0ffc | 2014-07-17 08:38:23 -0700 | [diff] [blame] | 1263 | SkDebugf("Timer overhead: %s\n", HUMANIZE(overhead)); |
Mike Klein | 9129477 | 2014-07-16 19:59:32 -0400 | [diff] [blame] | 1264 | |
cdalton | e1b8958 | 2015-06-25 19:17:08 -0700 | [diff] [blame] | 1265 | SkTArray<double> samples; |
mtklein | bb6a028 | 2014-07-01 08:43:42 -0700 | [diff] [blame] | 1266 | |
bsalomon | 6eb03cc | 2014-08-07 14:28:50 -0700 | [diff] [blame] | 1267 | if (kAutoTuneLoops != FLAGS_loops) { |
| 1268 | SkDebugf("Fixed number of loops; times would only be misleading so we won't print them.\n"); |
mtklein | f372321 | 2014-06-25 14:08:00 -0700 | [diff] [blame] | 1269 | } else if (FLAGS_quiet) { |
mtklein | 66cfcff | 2015-12-04 06:35:30 -0800 | [diff] [blame] | 1270 | SkDebugf("! -> high variance, ? -> moderate variance\n"); |
| 1271 | SkDebugf(" micros \tbench\n"); |
mtklein | bbba168 | 2015-10-28 11:36:30 -0700 | [diff] [blame] | 1272 | } else if (FLAGS_ms) { |
cdalton | e1b8958 | 2015-06-25 19:17:08 -0700 | [diff] [blame] | 1273 | SkDebugf("curr/maxrss\tloops\tmin\tmedian\tmean\tmax\tstddev\tsamples\tconfig\tbench\n"); |
mtklein | f372321 | 2014-06-25 14:08:00 -0700 | [diff] [blame] | 1274 | } else { |
mtklein | d75c466 | 2015-04-30 07:11:22 -0700 | [diff] [blame] | 1275 | SkDebugf("curr/maxrss\tloops\tmin\tmedian\tmean\tmax\tstddev\t%-*s\tconfig\tbench\n", |
qiankun.miao | 8247ec3 | 2014-09-09 19:24:36 -0700 | [diff] [blame] | 1276 | FLAGS_samples, "samples"); |
mtklein | f372321 | 2014-06-25 14:08:00 -0700 | [diff] [blame] | 1277 | } |
| 1278 | |
Chris Dalton | 5dfb3f4 | 2021-04-30 17:16:12 -0600 | [diff] [blame] | 1279 | GrRecordingContextPriv::DMSAAStats combinedDMSAAStats; |
| 1280 | |
svaisanen | c47635e | 2016-01-28 06:05:43 -0800 | [diff] [blame] | 1281 | SkTArray<Config> configs; |
bsalomon | c255337 | 2014-07-22 13:09:05 -0700 | [diff] [blame] | 1282 | create_configs(&configs); |
| 1283 | |
msarett | c149f0e | 2016-01-04 11:35:43 -0800 | [diff] [blame] | 1284 | if (FLAGS_keepAlive) { |
| 1285 | start_keepalive(); |
| 1286 | } |
| 1287 | |
Mike Klein | 03fa5d4 | 2019-03-22 11:39:09 -0500 | [diff] [blame] | 1288 | SetAnalyticAAFromCommonFlags(); |
liyuqian | 38911a7 | 2016-10-04 11:23:22 -0700 | [diff] [blame] | 1289 | |
Mike Reed | 0e2fb66 | 2021-07-23 11:00:40 -0400 | [diff] [blame] | 1290 | gSkForceRasterPipelineBlitter = FLAGS_forceRasterPipelineHP || FLAGS_forceRasterPipeline; |
| 1291 | gForceHighPrecisionRasterPipeline = FLAGS_forceRasterPipelineHP; |
Mike Klein | 813e8cc | 2020-08-05 09:33:38 -0500 | [diff] [blame] | 1292 | gUseSkVMBlitter = FLAGS_skvm; |
Mike Klein | f2b3f91 | 2021-03-23 14:32:45 -0500 | [diff] [blame] | 1293 | gSkVMAllowJIT = FLAGS_jit; |
| 1294 | gSkVMJITViaDylib = FLAGS_dylib; |
Yuqian Li | 550148b | 2017-01-13 10:13:13 -0500 | [diff] [blame] | 1295 | |
mtklein | e070c2b | 2014-10-14 08:40:43 -0700 | [diff] [blame] | 1296 | int runs = 0; |
mtklein | 9200758 | 2014-08-01 07:46:52 -0700 | [diff] [blame] | 1297 | BenchmarkStream benchStream; |
Brian Osman | 8c0a1ca | 2019-01-28 14:24:29 -0500 | [diff] [blame] | 1298 | log.beginObject("results"); |
Jim Van Verth | 8a9a371 | 2019-05-31 10:49:12 -0400 | [diff] [blame] | 1299 | AutoreleasePool pool; |
mtklein | 9200758 | 2014-08-01 07:46:52 -0700 | [diff] [blame] | 1300 | while (Benchmark* b = benchStream.next()) { |
Ben Wagner | 145dbcd | 2016-11-03 14:40:50 -0400 | [diff] [blame] | 1301 | std::unique_ptr<Benchmark> bench(b); |
Mike Klein | 88544fb | 2019-03-20 10:50:33 -0500 | [diff] [blame] | 1302 | if (CommandLineFlags::ShouldSkip(FLAGS_match, bench->getUniqueName())) { |
mtklein | f372321 | 2014-06-25 14:08:00 -0700 | [diff] [blame] | 1303 | continue; |
| 1304 | } |
| 1305 | |
svaisanen | c47635e | 2016-01-28 06:05:43 -0800 | [diff] [blame] | 1306 | if (!configs.empty()) { |
Brian Osman | 8c0a1ca | 2019-01-28 14:24:29 -0500 | [diff] [blame] | 1307 | log.beginBench(bench->getUniqueName(), bench->getSize().fX, bench->getSize().fY); |
joshualitt | 8a6697a | 2015-09-30 12:11:07 -0700 | [diff] [blame] | 1308 | bench->delayedSetup(); |
jcgregorio | bf5e523 | 2014-07-17 13:14:16 -0700 | [diff] [blame] | 1309 | } |
egdaniel | 3bf9206 | 2015-06-26 08:12:46 -0700 | [diff] [blame] | 1310 | for (int i = 0; i < configs.count(); ++i) { |
| 1311 | Target* target = is_enabled(b, configs[i]); |
| 1312 | if (!target) { |
| 1313 | continue; |
| 1314 | } |
mtklein | f372321 | 2014-06-25 14:08:00 -0700 | [diff] [blame] | 1315 | |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 1316 | // During HWUI output this canvas may be nullptr. |
egdaniel | 3bf9206 | 2015-06-26 08:12:46 -0700 | [diff] [blame] | 1317 | SkCanvas* canvas = target->getCanvas(); |
svaisanen | c47635e | 2016-01-28 06:05:43 -0800 | [diff] [blame] | 1318 | const char* config = target->config.name.c_str(); |
egdaniel | 3bf9206 | 2015-06-26 08:12:46 -0700 | [diff] [blame] | 1319 | |
brianosman | 7a5ada8 | 2016-02-08 13:49:12 -0800 | [diff] [blame] | 1320 | if (FLAGS_pre_log || FLAGS_dryRun) { |
benjaminwagner | 8d61f0d | 2016-01-25 13:02:40 -0800 | [diff] [blame] | 1321 | SkDebugf("Running %s\t%s\n" |
| 1322 | , bench->getUniqueName() |
| 1323 | , config); |
brianosman | 7a5ada8 | 2016-02-08 13:49:12 -0800 | [diff] [blame] | 1324 | if (FLAGS_dryRun) { |
| 1325 | continue; |
| 1326 | } |
benjaminwagner | 8d61f0d | 2016-01-25 13:02:40 -0800 | [diff] [blame] | 1327 | } |
| 1328 | |
Mike Klein | ee25423 | 2019-03-28 08:32:14 -0500 | [diff] [blame] | 1329 | if (FLAGS_purgeBetweenBenches) { |
| 1330 | SkGraphics::PurgeAllCaches(); |
| 1331 | } |
| 1332 | |
Brian Osman | 5ad87aa | 2017-09-08 16:05:23 -0400 | [diff] [blame] | 1333 | TRACE_EVENT2("skia", "Benchmark", "name", TRACE_STR_COPY(bench->getUniqueName()), |
| 1334 | "config", TRACE_STR_COPY(config)); |
Brian Osman | c3cdef5 | 2017-08-31 14:09:22 -0400 | [diff] [blame] | 1335 | |
egdaniel | 3bf9206 | 2015-06-26 08:12:46 -0700 | [diff] [blame] | 1336 | target->setup(); |
robertphillips | 5b69377 | 2014-11-21 06:19:36 -0800 | [diff] [blame] | 1337 | bench->perCanvasPreDraw(canvas); |
| 1338 | |
cdalton | e1b8958 | 2015-06-25 19:17:08 -0700 | [diff] [blame] | 1339 | int maxFrameLag; |
mtklein | a1ebeb2 | 2015-10-01 09:43:39 -0700 | [diff] [blame] | 1340 | int loops = target->needsFrameTiming(&maxFrameLag) |
egdaniel | 3bf9206 | 2015-06-26 08:12:46 -0700 | [diff] [blame] | 1341 | ? setup_gpu_bench(target, bench.get(), maxFrameLag) |
| 1342 | : setup_cpu_bench(overhead, target, bench.get()); |
cdalton | e1b8958 | 2015-06-25 19:17:08 -0700 | [diff] [blame] | 1343 | |
Leon Scroggins III | b30d113 | 2017-10-02 09:48:15 -0400 | [diff] [blame] | 1344 | if (kFailedLoops == loops) { |
| 1345 | // Can't be timed. A warning note has already been printed. |
| 1346 | cleanup_run(target); |
| 1347 | continue; |
| 1348 | } |
| 1349 | |
Yuqian Li | 3528eb3 | 2017-09-21 13:23:49 -0400 | [diff] [blame] | 1350 | if (runs == 0 && FLAGS_ms < 1000) { |
| 1351 | // Run the first bench for 1000ms to warm up the nanobench if FLAGS_ms < 1000. |
| 1352 | // Otherwise, the first few benches' measurements will be inaccurate. |
| 1353 | auto stop = now_ms() + 1000; |
| 1354 | do { |
| 1355 | time(loops, bench.get(), target); |
Jim Van Verth | 49d6bca | 2020-02-28 11:05:44 -0500 | [diff] [blame] | 1356 | pool.drain(); |
Yuqian Li | 3528eb3 | 2017-09-21 13:23:49 -0400 | [diff] [blame] | 1357 | } while (now_ms() < stop); |
| 1358 | } |
| 1359 | |
mtklein | bbba168 | 2015-10-28 11:36:30 -0700 | [diff] [blame] | 1360 | if (FLAGS_ms) { |
| 1361 | samples.reset(); |
| 1362 | auto stop = now_ms() + FLAGS_ms; |
| 1363 | do { |
Ben Wagner | 145dbcd | 2016-11-03 14:40:50 -0400 | [diff] [blame] | 1364 | samples.push_back(time(loops, bench.get(), target) / loops); |
Jim Van Verth | 49d6bca | 2020-02-28 11:05:44 -0500 | [diff] [blame] | 1365 | pool.drain(); |
mtklein | bbba168 | 2015-10-28 11:36:30 -0700 | [diff] [blame] | 1366 | } while (now_ms() < stop); |
| 1367 | } else { |
cdalton | e1b8958 | 2015-06-25 19:17:08 -0700 | [diff] [blame] | 1368 | samples.reset(FLAGS_samples); |
| 1369 | for (int s = 0; s < FLAGS_samples; s++) { |
Ben Wagner | 145dbcd | 2016-11-03 14:40:50 -0400 | [diff] [blame] | 1370 | samples[s] = time(loops, bench.get(), target) / loops; |
Jim Van Verth | 49d6bca | 2020-02-28 11:05:44 -0500 | [diff] [blame] | 1371 | pool.drain(); |
cdalton | e1b8958 | 2015-06-25 19:17:08 -0700 | [diff] [blame] | 1372 | } |
cdalton | e1b8958 | 2015-06-25 19:17:08 -0700 | [diff] [blame] | 1373 | } |
mtklein | f372321 | 2014-06-25 14:08:00 -0700 | [diff] [blame] | 1374 | |
Mike Klein | fec9b90 | 2019-05-31 10:03:07 -0500 | [diff] [blame] | 1375 | // Scale each result to the benchmark's own units, time/unit. |
| 1376 | for (double& sample : samples) { |
| 1377 | sample *= (1.0 / bench->getUnits()); |
| 1378 | } |
| 1379 | |
joshualitt | e45c81c | 2015-12-02 09:05:37 -0800 | [diff] [blame] | 1380 | SkTArray<SkString> keys; |
| 1381 | SkTArray<double> values; |
Chris Dalton | 5dfb3f4 | 2021-04-30 17:16:12 -0600 | [diff] [blame] | 1382 | if (configs[i].backend == Benchmark::kGPU_Backend) { |
| 1383 | if (FLAGS_gpuStatsDump) { |
| 1384 | // TODO cache stats |
| 1385 | bench->getGpuStats(canvas, &keys, &values); |
| 1386 | } |
| 1387 | if (FLAGS_dmsaaStatsDump && bench->getDMSAAStats(canvas->recordingContext())) { |
| 1388 | const auto& dmsaaStats = canvas->recordingContext()->priv().dmsaaStats(); |
| 1389 | dmsaaStats.dumpKeyValuePairs(&keys, &values); |
| 1390 | dmsaaStats.dump(); |
| 1391 | combinedDMSAAStats.merge(dmsaaStats); |
| 1392 | } |
joshualitt | e45c81c | 2015-12-02 09:05:37 -0800 | [diff] [blame] | 1393 | } |
joshualitt | e45c81c | 2015-12-02 09:05:37 -0800 | [diff] [blame] | 1394 | |
robertphillips | 5b69377 | 2014-11-21 06:19:36 -0800 | [diff] [blame] | 1395 | bench->perCanvasPostDraw(canvas); |
| 1396 | |
egdaniel | 3bf9206 | 2015-06-26 08:12:46 -0700 | [diff] [blame] | 1397 | if (Benchmark::kNonRendering_Backend != target->config.backend && |
tomhudson | d968a6f | 2015-03-26 11:28:06 -0700 | [diff] [blame] | 1398 | !FLAGS_writePath.isEmpty() && FLAGS_writePath[0]) { |
bsalomon | 6eb03cc | 2014-08-07 14:28:50 -0700 | [diff] [blame] | 1399 | SkString pngFilename = SkOSPath::Join(FLAGS_writePath[0], config); |
mtklein | 9628905 | 2014-09-10 12:05:59 -0700 | [diff] [blame] | 1400 | pngFilename = SkOSPath::Join(pngFilename.c_str(), bench->getUniqueName()); |
bsalomon | 6eb03cc | 2014-08-07 14:28:50 -0700 | [diff] [blame] | 1401 | pngFilename.append(".png"); |
egdaniel | 3bf9206 | 2015-06-26 08:12:46 -0700 | [diff] [blame] | 1402 | write_canvas_png(target, pngFilename); |
bsalomon | 6eb03cc | 2014-08-07 14:28:50 -0700 | [diff] [blame] | 1403 | } |
| 1404 | |
Mike Klein | 512a244 | 2018-09-27 10:44:56 -0400 | [diff] [blame] | 1405 | // Building stats.plot often shows up in profiles, |
| 1406 | // so skip building it when we're not going to print it anyway. |
| 1407 | const bool want_plot = !FLAGS_quiet; |
| 1408 | |
| 1409 | Stats stats(samples, want_plot); |
Brian Osman | 8c0a1ca | 2019-01-28 14:24:29 -0500 | [diff] [blame] | 1410 | log.beginObject(config); |
| 1411 | |
| 1412 | log.beginObject("options"); |
| 1413 | log.appendString("name", bench->getName()); |
| 1414 | benchStream.fillCurrentOptions(log); |
| 1415 | target->fillOptions(log); |
| 1416 | log.endObject(); // options |
| 1417 | |
| 1418 | // Metrics |
| 1419 | log.appendMetric("min_ms", stats.min); |
Joe Gregorio | f4f9c3b | 2021-06-01 09:39:11 -0400 | [diff] [blame] | 1420 | log.appendMetric("min_ratio", sk_ieee_double_divide(stats.median, stats.min)); |
Brian Osman | 8c0a1ca | 2019-01-28 14:24:29 -0500 | [diff] [blame] | 1421 | log.beginArray("samples"); |
| 1422 | for (double sample : samples) { |
| 1423 | log.appendDoubleDigits(sample, 16); |
| 1424 | } |
| 1425 | log.endArray(); // samples |
| 1426 | benchStream.fillCurrentMetrics(log); |
Chris Dalton | 5dfb3f4 | 2021-04-30 17:16:12 -0600 | [diff] [blame] | 1427 | if (!keys.empty()) { |
joshualitt | e45c81c | 2015-12-02 09:05:37 -0800 | [diff] [blame] | 1428 | // dump to json, only SKPBench currently returns valid keys / values |
| 1429 | SkASSERT(keys.count() == values.count()); |
| 1430 | for (int i = 0; i < keys.count(); i++) { |
Brian Osman | 8c0a1ca | 2019-01-28 14:24:29 -0500 | [diff] [blame] | 1431 | log.appendMetric(keys[i].c_str(), values[i]); |
joshualitt | e45c81c | 2015-12-02 09:05:37 -0800 | [diff] [blame] | 1432 | } |
| 1433 | } |
joshualitt | e45c81c | 2015-12-02 09:05:37 -0800 | [diff] [blame] | 1434 | |
Brian Osman | 8c0a1ca | 2019-01-28 14:24:29 -0500 | [diff] [blame] | 1435 | log.endObject(); // config |
| 1436 | |
mtklein | e070c2b | 2014-10-14 08:40:43 -0700 | [diff] [blame] | 1437 | if (runs++ % FLAGS_flushEvery == 0) { |
Brian Osman | 8c0a1ca | 2019-01-28 14:24:29 -0500 | [diff] [blame] | 1438 | log.flush(); |
mtklein | e070c2b | 2014-10-14 08:40:43 -0700 | [diff] [blame] | 1439 | } |
mtklein | 60317d0f | 2014-07-14 11:30:37 -0700 | [diff] [blame] | 1440 | |
bsalomon | 6eb03cc | 2014-08-07 14:28:50 -0700 | [diff] [blame] | 1441 | if (kAutoTuneLoops != FLAGS_loops) { |
egdaniel | 3bf9206 | 2015-06-26 08:12:46 -0700 | [diff] [blame] | 1442 | if (configs.count() == 1) { |
mtklein | a189ccd | 2014-07-14 12:28:47 -0700 | [diff] [blame] | 1443 | config = ""; // Only print the config if we run the same bench on more than one. |
| 1444 | } |
mtklein | d75c466 | 2015-04-30 07:11:22 -0700 | [diff] [blame] | 1445 | SkDebugf("%4d/%-4dMB\t%s\t%s\n" |
| 1446 | , sk_tools::getCurrResidentSetSizeMB() |
| 1447 | , sk_tools::getMaxResidentSetSizeMB() |
mtklein | 53d2562 | 2014-09-18 07:39:42 -0700 | [diff] [blame] | 1448 | , bench->getUniqueName() |
| 1449 | , config); |
mtklein | f372321 | 2014-06-25 14:08:00 -0700 | [diff] [blame] | 1450 | } else if (FLAGS_quiet) { |
mtklein | 66cfcff | 2015-12-04 06:35:30 -0800 | [diff] [blame] | 1451 | const char* mark = " "; |
Hal Canary | e99e8da | 2019-01-14 16:34:50 -0500 | [diff] [blame] | 1452 | const double stddev_percent = |
| 1453 | sk_ieee_double_divide(100 * sqrt(stats.var), stats.mean); |
mtklein | 66cfcff | 2015-12-04 06:35:30 -0800 | [diff] [blame] | 1454 | if (stddev_percent > 5) mark = "?"; |
| 1455 | if (stddev_percent > 10) mark = "!"; |
| 1456 | |
| 1457 | SkDebugf("%10.2f %s\t%s\t%s\n", |
| 1458 | stats.median*1e3, mark, bench->getUniqueName(), config); |
Mike Reed | c665e5b | 2017-07-04 22:56:06 -0400 | [diff] [blame] | 1459 | } else if (FLAGS_csv) { |
Hal Canary | e99e8da | 2019-01-14 16:34:50 -0500 | [diff] [blame] | 1460 | const double stddev_percent = |
| 1461 | sk_ieee_double_divide(100 * sqrt(stats.var), stats.mean); |
Mike Reed | c665e5b | 2017-07-04 22:56:06 -0400 | [diff] [blame] | 1462 | SkDebugf("%g,%g,%g,%g,%g,%s,%s\n" |
| 1463 | , stats.min |
| 1464 | , stats.median |
| 1465 | , stats.mean |
| 1466 | , stats.max |
| 1467 | , stddev_percent |
| 1468 | , config |
| 1469 | , bench->getUniqueName() |
| 1470 | ); |
| 1471 | } else { |
| 1472 | const char* format = "%4d/%-4dMB\t%d\t%s\t%s\t%s\t%s\t%.0f%%\t%s\t%s\t%s\n"; |
Hal Canary | e99e8da | 2019-01-14 16:34:50 -0500 | [diff] [blame] | 1473 | const double stddev_percent = |
| 1474 | sk_ieee_double_divide(100 * sqrt(stats.var), stats.mean); |
Mike Reed | c665e5b | 2017-07-04 22:56:06 -0400 | [diff] [blame] | 1475 | SkDebugf(format |
mtklein | d75c466 | 2015-04-30 07:11:22 -0700 | [diff] [blame] | 1476 | , sk_tools::getCurrResidentSetSizeMB() |
| 1477 | , sk_tools::getMaxResidentSetSizeMB() |
mtklein | f372321 | 2014-06-25 14:08:00 -0700 | [diff] [blame] | 1478 | , loops |
mtklein | 55b0ffc | 2014-07-17 08:38:23 -0700 | [diff] [blame] | 1479 | , HUMANIZE(stats.min) |
| 1480 | , HUMANIZE(stats.median) |
| 1481 | , HUMANIZE(stats.mean) |
| 1482 | , HUMANIZE(stats.max) |
mtklein | f372321 | 2014-06-25 14:08:00 -0700 | [diff] [blame] | 1483 | , stddev_percent |
mtklein | bbba168 | 2015-10-28 11:36:30 -0700 | [diff] [blame] | 1484 | , FLAGS_ms ? to_string(samples.count()).c_str() : stats.plot.c_str() |
mtklein | f372321 | 2014-06-25 14:08:00 -0700 | [diff] [blame] | 1485 | , config |
mtklein | 9628905 | 2014-09-10 12:05:59 -0700 | [diff] [blame] | 1486 | , bench->getUniqueName() |
mtklein | f372321 | 2014-06-25 14:08:00 -0700 | [diff] [blame] | 1487 | ); |
| 1488 | } |
joshualitt | e45c81c | 2015-12-02 09:05:37 -0800 | [diff] [blame] | 1489 | |
joshualitt | e45c81c | 2015-12-02 09:05:37 -0800 | [diff] [blame] | 1490 | if (FLAGS_gpuStats && Benchmark::kGPU_Backend == configs[i].backend) { |
Brian Salomon | 0b4d8aa | 2017-10-11 15:34:27 -0400 | [diff] [blame] | 1491 | target->dumpStats(); |
bsalomon | 06cddec | 2014-10-24 10:40:50 -0700 | [diff] [blame] | 1492 | } |
joshualitt | e45c81c | 2015-12-02 09:05:37 -0800 | [diff] [blame] | 1493 | |
cdalton | 2c56ba5 | 2015-06-26 13:32:53 -0700 | [diff] [blame] | 1494 | if (FLAGS_verbose) { |
| 1495 | SkDebugf("Samples: "); |
| 1496 | for (int i = 0; i < samples.count(); i++) { |
| 1497 | SkDebugf("%s ", HUMANIZE(samples[i])); |
| 1498 | } |
| 1499 | SkDebugf("%s\n", bench->getUniqueName()); |
| 1500 | } |
egdaniel | 3bf9206 | 2015-06-26 08:12:46 -0700 | [diff] [blame] | 1501 | cleanup_run(target); |
Jim Van Verth | 8a9a371 | 2019-05-31 10:49:12 -0400 | [diff] [blame] | 1502 | pool.drain(); |
mtklein | f372321 | 2014-06-25 14:08:00 -0700 | [diff] [blame] | 1503 | } |
Brian Osman | 8c0a1ca | 2019-01-28 14:24:29 -0500 | [diff] [blame] | 1504 | if (!configs.empty()) { |
| 1505 | log.endBench(); |
| 1506 | } |
mtklein | f372321 | 2014-06-25 14:08:00 -0700 | [diff] [blame] | 1507 | } |
| 1508 | |
Chris Dalton | 5dfb3f4 | 2021-04-30 17:16:12 -0600 | [diff] [blame] | 1509 | if (FLAGS_dmsaaStatsDump) { |
| 1510 | SkDebugf("<<Total Combined DMSAA Stats>>\n"); |
| 1511 | combinedDMSAAStats.dump(); |
| 1512 | } |
| 1513 | |
Herb Derby | 5a523fe | 2017-01-26 16:48:28 -0500 | [diff] [blame] | 1514 | SkGraphics::PurgeAllCaches(); |
| 1515 | |
Brian Osman | 8c0a1ca | 2019-01-28 14:24:29 -0500 | [diff] [blame] | 1516 | log.beginBench("memory_usage", 0, 0); |
| 1517 | log.beginObject("meta"); // config |
| 1518 | log.appendS32("max_rss_mb", sk_tools::getMaxResidentSetSizeMB()); |
| 1519 | log.endObject(); // config |
| 1520 | log.endBench(); |
| 1521 | |
Brian Osman | 68870aa | 2020-07-08 14:12:43 -0400 | [diff] [blame] | 1522 | RunSkSLMemoryBenchmarks(&log); |
| 1523 | |
Brian Osman | 8c0a1ca | 2019-01-28 14:24:29 -0500 | [diff] [blame] | 1524 | log.endObject(); // results |
| 1525 | log.endObject(); // root |
| 1526 | log.flush(); |
mtklein | e109145 | 2014-12-04 10:47:02 -0800 | [diff] [blame] | 1527 | |
mtklein | f372321 | 2014-06-25 14:08:00 -0700 | [diff] [blame] | 1528 | return 0; |
| 1529 | } |