2014-06-25 21:08:00 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2014 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2014-07-01 15:43:42 +00:00
|
|
|
#include <ctype.h>
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "bench/nanobench.h"
|
|
|
|
|
|
|
|
#include "bench/AndroidCodecBench.h"
|
|
|
|
#include "bench/Benchmark.h"
|
|
|
|
#include "bench/CodecBench.h"
|
|
|
|
#include "bench/CodecBenchPriv.h"
|
|
|
|
#include "bench/GMBench.h"
|
2021-04-30 17:08:55 +00:00
|
|
|
#include "bench/MSKPBench.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "bench/RecordingBench.h"
|
|
|
|
#include "bench/ResultsWriter.h"
|
|
|
|
#include "bench/SKPAnimationBench.h"
|
|
|
|
#include "bench/SKPBench.h"
|
2019-10-24 17:52:17 +00:00
|
|
|
#include "bench/SkGlyphCacheBench.h"
|
2020-07-08 18:12:43 +00:00
|
|
|
#include "bench/SkSLBench.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/codec/SkAndroidCodec.h"
|
|
|
|
#include "include/codec/SkCodec.h"
|
|
|
|
#include "include/core/SkCanvas.h"
|
|
|
|
#include "include/core/SkData.h"
|
|
|
|
#include "include/core/SkGraphics.h"
|
|
|
|
#include "include/core/SkPictureRecorder.h"
|
|
|
|
#include "include/core/SkString.h"
|
|
|
|
#include "include/core/SkSurface.h"
|
2019-07-12 16:51:44 +00:00
|
|
|
#include "include/core/SkTime.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "src/core/SkAutoMalloc.h"
|
|
|
|
#include "src/core/SkColorSpacePriv.h"
|
2019-05-20 15:02:49 +00:00
|
|
|
#include "src/core/SkLeanWindows.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "src/core/SkOSFile.h"
|
|
|
|
#include "src/core/SkTaskGroup.h"
|
|
|
|
#include "src/core/SkTraceEvent.h"
|
2021-03-23 14:25:02 +00:00
|
|
|
#include "src/gpu/GrShaderUtils.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "src/utils/SkJSONWriter.h"
|
|
|
|
#include "src/utils/SkOSPath.h"
|
2019-05-31 14:49:12 +00:00
|
|
|
#include "tools/AutoreleasePool.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "tools/CrashHandler.h"
|
2021-04-30 17:08:55 +00:00
|
|
|
#include "tools/MSKPPlayer.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "tools/ProcStats.h"
|
|
|
|
#include "tools/Stats.h"
|
|
|
|
#include "tools/flags/CommonFlags.h"
|
|
|
|
#include "tools/flags/CommonFlagsConfig.h"
|
|
|
|
#include "tools/ios_utils.h"
|
|
|
|
#include "tools/trace/EventTracingPriv.h"
|
|
|
|
#include "tools/trace/SkDebugfTracer.h"
|
2014-06-25 21:08:00 +00:00
|
|
|
|
2018-03-22 19:21:12 +00:00
|
|
|
#ifdef SK_XML
|
2020-10-15 22:10:29 +00:00
|
|
|
#include "modules/svg/include/SkSVGDOM.h"
|
2018-03-22 19:21:12 +00:00
|
|
|
#endif // SK_XML
|
|
|
|
|
2020-05-04 14:02:45 +00:00
|
|
|
#ifdef SK_ENABLE_ANDROID_UTILS
|
|
|
|
#include "bench/BitmapRegionDecoderBench.h"
|
|
|
|
#include "client_utils/android/BitmapRegionDecoder.h"
|
|
|
|
#endif
|
|
|
|
|
2020-05-12 14:41:04 +00:00
|
|
|
#include <cinttypes>
|
2015-08-26 12:15:46 +00:00
|
|
|
#include <stdlib.h>
|
2020-08-03 17:21:46 +00:00
|
|
|
#include <memory>
|
2017-10-30 15:57:15 +00:00
|
|
|
#include <thread>
|
2015-08-26 12:15:46 +00:00
|
|
|
|
2017-06-05 14:20:31 +00:00
|
|
|
extern bool gSkForceRasterPipelineBlitter;
|
2020-01-14 18:47:52 +00:00
|
|
|
extern bool gUseSkVMBlitter;
|
2020-08-05 14:33:38 +00:00
|
|
|
extern bool gSkVMAllowJIT;
|
2020-01-16 19:05:04 +00:00
|
|
|
extern bool gSkVMJITViaDylib;
|
2017-06-05 14:20:31 +00:00
|
|
|
|
2018-01-24 17:42:55 +00:00
|
|
|
#ifndef SK_BUILD_FOR_WIN
|
2016-01-07 15:28:47 +00:00
|
|
|
#include <unistd.h>
|
2018-03-23 20:10:36 +00:00
|
|
|
|
2016-01-07 15:28:47 +00:00
|
|
|
#endif
|
|
|
|
|
2020-07-01 20:09:43 +00:00
|
|
|
#include "include/gpu/GrDirectContext.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "src/gpu/GrCaps.h"
|
2020-10-14 15:23:11 +00:00
|
|
|
#include "src/gpu/GrDirectContextPriv.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "src/gpu/SkGr.h"
|
|
|
|
#include "src/gpu/gl/GrGLDefines.h"
|
|
|
|
#include "src/gpu/gl/GrGLGpu.h"
|
|
|
|
#include "src/gpu/gl/GrGLUtil.h"
|
|
|
|
#include "tools/gpu/GrContextFactory.h"
|
2018-05-31 18:27:17 +00:00
|
|
|
|
|
|
|
using sk_gpu_test::ContextInfo;
|
|
|
|
using sk_gpu_test::GrContextFactory;
|
|
|
|
using sk_gpu_test::TestContext;
|
2014-07-01 15:43:42 +00:00
|
|
|
|
2018-05-31 18:27:17 +00:00
|
|
|
GrContextOptions grContextOpts;
|
2015-05-22 21:01:46 +00:00
|
|
|
|
2014-10-10 16:09:52 +00:00
|
|
|
static const int kAutoTuneLoops = 0;
|
2014-08-07 21:28:50 +00:00
|
|
|
|
|
|
|
static SkString loops_help_txt() {
|
|
|
|
SkString help;
|
|
|
|
help.printf("Number of times to run each bench. Set this to %d to auto-"
|
|
|
|
"tune for each bench. Timings are only reported when auto-tuning.",
|
|
|
|
kAutoTuneLoops);
|
|
|
|
return help;
|
|
|
|
}
|
|
|
|
|
2015-06-26 02:17:08 +00:00
|
|
|
static SkString to_string(int n) {
|
|
|
|
SkString str;
|
|
|
|
str.appendS32(n);
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2019-07-01 15:15:32 +00:00
|
|
|
static DEFINE_int(loops, kAutoTuneLoops, loops_help_txt().c_str());
|
2014-08-07 21:28:50 +00:00
|
|
|
|
2019-03-21 16:42:21 +00:00
|
|
|
static DEFINE_int(samples, 10, "Number of samples to measure for each bench.");
|
|
|
|
static DEFINE_int(ms, 0, "If >0, run each bench for this many ms instead of obeying --samples.");
|
|
|
|
static DEFINE_int(overheadLoops, 100000, "Loops to estimate timer overhead.");
|
2019-03-21 16:31:36 +00:00
|
|
|
static DEFINE_double(overheadGoal, 0.0001,
|
2014-06-25 21:08:00 +00:00
|
|
|
"Loop until timer overhead is at most this fraction of our measurments.");
|
2019-03-21 16:31:36 +00:00
|
|
|
static DEFINE_double(gpuMs, 5, "Target bench time in millseconds for GPU.");
|
2019-03-21 16:42:21 +00:00
|
|
|
static DEFINE_int(gpuFrameLag, 5,
|
2019-03-21 16:31:36 +00:00
|
|
|
"If unknown, estimated maximum number of frames GPU allows to lag.");
|
2014-06-25 21:08:00 +00:00
|
|
|
|
2019-03-21 16:31:36 +00:00
|
|
|
static DEFINE_string(outResultsFile, "", "If given, write results here as JSON.");
|
2019-03-21 16:42:21 +00:00
|
|
|
static DEFINE_int(maxCalibrationAttempts, 3,
|
2014-07-17 15:38:23 +00:00
|
|
|
"Try up to this many times to guess loops for a bench, or skip the bench.");
|
2019-03-21 16:42:21 +00:00
|
|
|
static DEFINE_int(maxLoops, 1000000, "Never run a bench more times than this.");
|
2019-03-21 16:31:36 +00:00
|
|
|
static DEFINE_string(clip, "0,0,1000,1000", "Clip for SKPs.");
|
|
|
|
static DEFINE_string(scales, "1.0", "Space-separated scales for SKPs.");
|
|
|
|
static DEFINE_string(zoom, "1.0,0",
|
|
|
|
"Comma-separated zoomMax,zoomPeriodMs factors for a periodic SKP zoom "
|
|
|
|
"function that ping-pongs between 1.0 and zoomMax.");
|
|
|
|
static DEFINE_bool(bbh, true, "Build a BBH for SKPs?");
|
|
|
|
static DEFINE_bool(loopSKP, true, "Loop SKPs like we do for micro benches?");
|
2019-03-21 16:42:21 +00:00
|
|
|
static DEFINE_int(flushEvery, 10, "Flush --outResultsFile every Nth run.");
|
2019-03-21 16:31:36 +00:00
|
|
|
static DEFINE_bool(gpuStats, false, "Print GPU stats after each gpu benchmark?");
|
2021-04-30 23:16:12 +00:00
|
|
|
static DEFINE_bool(gpuStatsDump, false, "Dump GPU stats after each benchmark to json");
|
|
|
|
static DEFINE_bool(dmsaaStatsDump, false, "Dump DMSAA stats after each benchmark to json");
|
2019-03-21 16:31:36 +00:00
|
|
|
static DEFINE_bool(keepAlive, false, "Print a message every so often so that we don't time out");
|
|
|
|
static DEFINE_bool(csv, false, "Print status in CSV format");
|
|
|
|
static DEFINE_string(sourceType, "",
|
2016-02-03 18:40:54 +00:00
|
|
|
"Apply usual --match rules to source type: bench, gm, skp, image, etc.");
|
2019-03-21 16:31:36 +00:00
|
|
|
static DEFINE_string(benchType, "",
|
|
|
|
"Apply usual --match rules to bench type: micro, recording, "
|
|
|
|
"piping, playback, skcodec, etc.");
|
2016-02-03 18:40:54 +00:00
|
|
|
|
2019-03-21 16:31:36 +00:00
|
|
|
static DEFINE_bool(forceRasterPipeline, false, "sets gSkForceRasterPipelineBlitter");
|
2020-08-05 14:33:38 +00:00
|
|
|
static DEFINE_bool(skvm, false, "sets gUseSkVMBlitter");
|
2021-03-23 19:32:45 +00:00
|
|
|
static DEFINE_bool(jit, true, "JIT SkVM?");
|
|
|
|
static DEFINE_bool(dylib, false, "JIT via dylib (much slower compile but easier to debug/profile)");
|
2017-06-05 14:20:31 +00:00
|
|
|
|
2019-03-21 18:08:08 +00:00
|
|
|
static DEFINE_bool2(pre_log, p, false,
|
|
|
|
"Log before running each test. May be incomprehensible when threading");
|
|
|
|
|
2020-07-27 18:52:19 +00:00
|
|
|
static DEFINE_bool(cpu, true, "Run CPU-bound work?");
|
|
|
|
static DEFINE_bool(gpu, true, "Run GPU-bound work?");
|
2019-03-22 19:55:19 +00:00
|
|
|
static DEFINE_bool(dryRun, false,
|
|
|
|
"just print the tests that would be run, without actually running them.");
|
|
|
|
static DEFINE_string(images, "",
|
|
|
|
"List of images and/or directories to decode. A directory with no images"
|
|
|
|
" is treated as a fatal error.");
|
|
|
|
static DEFINE_bool(simpleCodec, false,
|
|
|
|
"Runs of a subset of the codec tests, always N32, Premul or Opaque");
|
|
|
|
|
2019-03-25 15:54:59 +00:00
|
|
|
static DEFINE_string2(match, m, nullptr,
|
|
|
|
"[~][^]substring[$] [...] of name to run.\n"
|
|
|
|
"Multiple matches may be separated by spaces.\n"
|
|
|
|
"~ causes a matching name to always be skipped\n"
|
|
|
|
"^ requires the start of the name to match\n"
|
|
|
|
"$ requires the end of the name to match\n"
|
|
|
|
"^ and $ requires an exact match\n"
|
|
|
|
"If a name does not match any list entry,\n"
|
|
|
|
"it is skipped unless some list entry starts with ~");
|
|
|
|
|
|
|
|
static DEFINE_bool2(quiet, q, false, "if true, don't print status updates.");
|
|
|
|
static DEFINE_bool2(verbose, v, false, "enable verbose output from the test driver.");
|
|
|
|
|
|
|
|
|
|
|
|
static DEFINE_string(skps, "skps", "Directory to read skps from.");
|
2021-04-30 17:08:55 +00:00
|
|
|
static DEFINE_string(mskps, "mskps", "Directory to read mskps from.");
|
2019-03-25 15:54:59 +00:00
|
|
|
static DEFINE_string(svgs, "", "Directory to read SVGs from, or a single SVG file.");
|
2019-10-24 17:52:17 +00:00
|
|
|
static DEFINE_string(texttraces, "", "Directory to read TextBlobTrace files from.");
|
2019-03-25 15:54:59 +00:00
|
|
|
|
|
|
|
static DEFINE_int_2(threads, j, -1,
|
|
|
|
"Run threadsafe tests on a threadpool with this many extra threads, "
|
|
|
|
"defaulting to one extra thread per core.");
|
|
|
|
|
|
|
|
static DEFINE_string2(writePath, w, "", "If set, write bitmaps here as .pngs.");
|
|
|
|
|
|
|
|
static DEFINE_string(key, "",
|
|
|
|
"Space-separated key/value pairs to add to JSON identifying this builder.");
|
|
|
|
static DEFINE_string(properties, "",
|
|
|
|
"Space-separated key/value pairs to add to JSON identifying this run.");
|
|
|
|
|
2019-03-28 13:32:14 +00:00
|
|
|
static DEFINE_bool(purgeBetweenBenches, false,
|
|
|
|
"Call SkGraphics::PurgeAllCaches() between each benchmark?");
|
|
|
|
|
2015-10-28 18:36:30 +00:00
|
|
|
static double now_ms() { return SkTime::GetNSecs() * 1e-6; }
|
|
|
|
|
2014-06-25 21:08:00 +00:00
|
|
|
static SkString humanize(double ms) {
|
2020-05-12 14:41:04 +00:00
|
|
|
if (FLAGS_verbose) return SkStringPrintf("%" PRIu64, (uint64_t)(ms*1e6));
|
2015-01-15 18:56:12 +00:00
|
|
|
return HumanizeMs(ms);
|
2014-06-25 21:08:00 +00:00
|
|
|
}
|
2014-07-17 15:38:23 +00:00
|
|
|
#define HUMANIZE(ms) humanize(ms).c_str()
|
2014-06-25 21:08:00 +00:00
|
|
|
|
2015-03-26 18:28:06 +00:00
|
|
|
bool Target::init(SkImageInfo info, Benchmark* bench) {
|
|
|
|
if (Benchmark::kRaster_Backend == config.backend) {
|
2016-03-24 01:59:25 +00:00
|
|
|
this->surface = SkSurface::MakeRaster(info);
|
|
|
|
if (!this->surface) {
|
2015-03-26 18:28:06 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
bool Target::capturePixels(SkBitmap* bmp) {
|
2015-03-27 19:11:44 +00:00
|
|
|
SkCanvas* canvas = this->getCanvas();
|
2015-03-26 18:28:06 +00:00
|
|
|
if (!canvas) {
|
|
|
|
return false;
|
|
|
|
}
|
2017-04-17 14:53:29 +00:00
|
|
|
bmp->allocPixels(canvas->imageInfo());
|
|
|
|
if (!canvas->readPixels(*bmp, 0, 0)) {
|
2015-03-26 18:28:06 +00:00
|
|
|
SkDebugf("Can't read canvas pixels.\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct GPUTarget : public Target {
|
2017-10-11 19:34:27 +00:00
|
|
|
explicit GPUTarget(const Config& c) : Target(c) {}
|
|
|
|
ContextInfo contextInfo;
|
|
|
|
std::unique_ptr<GrContextFactory> factory;
|
2015-03-26 18:28:06 +00:00
|
|
|
|
2020-06-18 19:59:17 +00:00
|
|
|
~GPUTarget() override {
|
|
|
|
// For Vulkan we need to release all our refs to the GrContext before destroy the vulkan
|
|
|
|
// context which happens at the end of this destructor. Thus we need to release the surface
|
|
|
|
// here which holds a ref to the GrContext.
|
|
|
|
surface.reset();
|
|
|
|
}
|
|
|
|
|
2015-03-26 18:28:06 +00:00
|
|
|
void setup() override {
|
2017-10-11 19:34:27 +00:00
|
|
|
this->contextInfo.testContext()->makeCurrent();
|
2015-03-26 18:28:06 +00:00
|
|
|
// Make sure we're done with whatever came before.
|
2017-10-11 19:34:27 +00:00
|
|
|
this->contextInfo.testContext()->finish();
|
2015-03-26 18:28:06 +00:00
|
|
|
}
|
|
|
|
void endTiming() override {
|
2017-10-11 19:34:27 +00:00
|
|
|
if (this->contextInfo.testContext()) {
|
2020-07-01 20:09:43 +00:00
|
|
|
this->contextInfo.testContext()->flushAndWaitOnSync(contextInfo.directContext());
|
2015-03-26 18:28:06 +00:00
|
|
|
}
|
|
|
|
}
|
2017-10-11 19:34:27 +00:00
|
|
|
void fence() override { this->contextInfo.testContext()->finish(); }
|
2015-04-30 14:11:22 +00:00
|
|
|
|
2015-06-23 20:23:44 +00:00
|
|
|
bool needsFrameTiming(int* maxFrameLag) const override {
|
2017-10-11 19:34:27 +00:00
|
|
|
if (!this->contextInfo.testContext()->getMaxGpuFrameLag(maxFrameLag)) {
|
2015-06-23 20:23:44 +00:00
|
|
|
// Frame lag is unknown.
|
|
|
|
*maxFrameLag = FLAGS_gpuFrameLag;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2015-03-26 18:28:06 +00:00
|
|
|
bool init(SkImageInfo info, Benchmark* bench) override {
|
2017-10-11 19:34:27 +00:00
|
|
|
GrContextOptions options = grContextOpts;
|
|
|
|
bench->modifyGrContextOptions(&options);
|
2020-08-03 17:21:46 +00:00
|
|
|
this->factory = std::make_unique<GrContextFactory>(options);
|
2021-03-17 02:49:15 +00:00
|
|
|
SkSurfaceProps props(this->config.surfaceFlags, kRGB_H_SkPixelGeometry);
|
2017-10-11 19:34:27 +00:00
|
|
|
this->surface = SkSurface::MakeRenderTarget(
|
|
|
|
this->factory->get(this->config.ctxType, this->config.ctxOverrides),
|
|
|
|
SkBudgeted::kNo, info, this->config.samples, &props);
|
|
|
|
this->contextInfo =
|
|
|
|
this->factory->getContextInfo(this->config.ctxType, this->config.ctxOverrides);
|
2020-08-16 12:48:02 +00:00
|
|
|
if (!this->surface) {
|
2015-03-26 18:28:06 +00:00
|
|
|
return false;
|
|
|
|
}
|
2017-10-11 19:34:27 +00:00
|
|
|
if (!this->contextInfo.testContext()->fenceSyncSupport()) {
|
2015-06-23 20:23:44 +00:00
|
|
|
SkDebugf("WARNING: GL context for config \"%s\" does not support fence sync. "
|
2016-01-28 14:05:43 +00:00
|
|
|
"Timings might not be accurate.\n", this->config.name.c_str());
|
2015-06-23 20:23:44 +00:00
|
|
|
}
|
2015-03-26 18:28:06 +00:00
|
|
|
return true;
|
|
|
|
}
|
2019-01-28 19:24:29 +00:00
|
|
|
void fillOptions(NanoJSONResultsWriter& log) override {
|
2020-03-19 19:54:28 +00:00
|
|
|
#ifdef SK_GL
|
2015-03-26 18:28:06 +00:00
|
|
|
const GrGLubyte* version;
|
2018-10-12 13:31:11 +00:00
|
|
|
if (this->contextInfo.backend() == GrBackendApi::kOpenGL) {
|
2018-03-23 20:10:36 +00:00
|
|
|
const GrGLInterface* gl =
|
2020-07-01 20:09:43 +00:00
|
|
|
static_cast<GrGLGpu*>(this->contextInfo.directContext()->priv().getGpu())
|
2018-03-23 20:10:36 +00:00
|
|
|
->glInterface();
|
2016-05-11 18:55:36 +00:00
|
|
|
GR_GL_CALL_RET(gl, version, GetString(GR_GL_VERSION));
|
2019-01-28 19:24:29 +00:00
|
|
|
log.appendString("GL_VERSION", (const char*)(version));
|
2015-03-26 18:28:06 +00:00
|
|
|
|
2016-05-11 18:55:36 +00:00
|
|
|
GR_GL_CALL_RET(gl, version, GetString(GR_GL_RENDERER));
|
2019-01-28 19:24:29 +00:00
|
|
|
log.appendString("GL_RENDERER", (const char*) version);
|
2015-03-26 18:28:06 +00:00
|
|
|
|
2016-05-11 18:55:36 +00:00
|
|
|
GR_GL_CALL_RET(gl, version, GetString(GR_GL_VENDOR));
|
2019-01-28 19:24:29 +00:00
|
|
|
log.appendString("GL_VENDOR", (const char*) version);
|
2015-03-26 18:28:06 +00:00
|
|
|
|
2016-05-11 18:55:36 +00:00
|
|
|
GR_GL_CALL_RET(gl, version, GetString(GR_GL_SHADING_LANGUAGE_VERSION));
|
2019-01-28 19:24:29 +00:00
|
|
|
log.appendString("GL_SHADING_LANGUAGE_VERSION", (const char*) version);
|
2016-05-11 18:55:36 +00:00
|
|
|
}
|
2020-03-19 19:54:28 +00:00
|
|
|
#endif
|
2015-03-26 18:28:06 +00:00
|
|
|
}
|
2017-10-11 19:34:27 +00:00
|
|
|
|
|
|
|
void dumpStats() override {
|
2020-07-01 20:09:43 +00:00
|
|
|
auto context = this->contextInfo.directContext();
|
|
|
|
|
|
|
|
context->priv().printCacheStats();
|
|
|
|
context->priv().printGpuStats();
|
|
|
|
context->priv().printContextStats();
|
2017-10-11 19:34:27 +00:00
|
|
|
}
|
2015-03-26 18:28:06 +00:00
|
|
|
};
|
2015-04-30 14:11:22 +00:00
|
|
|
|
2015-03-27 19:11:44 +00:00
|
|
|
static double time(int loops, Benchmark* bench, Target* target) {
|
|
|
|
SkCanvas* canvas = target->getCanvas();
|
2014-08-07 21:28:50 +00:00
|
|
|
if (canvas) {
|
|
|
|
canvas->clear(SK_ColorWHITE);
|
|
|
|
}
|
2015-09-30 19:11:07 +00:00
|
|
|
bench->preDraw(canvas);
|
2015-10-28 18:36:30 +00:00
|
|
|
double start = now_ms();
|
2015-03-27 19:11:44 +00:00
|
|
|
canvas = target->beginTiming(canvas);
|
|
|
|
bench->draw(loops, canvas);
|
|
|
|
target->endTiming();
|
2015-10-28 18:36:30 +00:00
|
|
|
double elapsed = now_ms() - start;
|
2015-09-30 19:11:07 +00:00
|
|
|
bench->postDraw(canvas);
|
2015-10-28 18:36:30 +00:00
|
|
|
return elapsed;
|
2014-06-25 21:08:00 +00:00
|
|
|
}
|
|
|
|
|
2014-07-01 15:43:42 +00:00
|
|
|
static double estimate_timer_overhead() {
|
|
|
|
double overhead = 0;
|
|
|
|
for (int i = 0; i < FLAGS_overheadLoops; i++) {
|
2015-10-28 18:36:30 +00:00
|
|
|
double start = now_ms();
|
|
|
|
overhead += now_ms() - start;
|
2014-07-01 15:43:42 +00:00
|
|
|
}
|
|
|
|
return overhead / FLAGS_overheadLoops;
|
|
|
|
}
|
2014-06-25 21:08:00 +00:00
|
|
|
|
2014-10-10 16:09:52 +00:00
|
|
|
static int detect_forever_loops(int loops) {
|
|
|
|
// look for a magic run-forever value
|
|
|
|
if (loops < 0) {
|
|
|
|
loops = SK_MaxS32;
|
|
|
|
}
|
|
|
|
return loops;
|
|
|
|
}
|
|
|
|
|
2014-07-17 15:38:23 +00:00
|
|
|
static int clamp_loops(int loops) {
|
|
|
|
if (loops < 1) {
|
2014-11-06 16:04:34 +00:00
|
|
|
SkDebugf("ERROR: clamping loops from %d to 1. "
|
|
|
|
"There's probably something wrong with the bench.\n", loops);
|
2014-07-17 15:38:23 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (loops > FLAGS_maxLoops) {
|
|
|
|
SkDebugf("WARNING: clamping loops from %d to FLAGS_maxLoops, %d.\n", loops, FLAGS_maxLoops);
|
|
|
|
return FLAGS_maxLoops;
|
|
|
|
}
|
|
|
|
return loops;
|
|
|
|
}
|
|
|
|
|
2015-03-26 18:28:06 +00:00
|
|
|
static bool write_canvas_png(Target* target, const SkString& filename) {
|
|
|
|
|
2014-08-07 21:28:50 +00:00
|
|
|
if (filename.isEmpty()) {
|
|
|
|
return false;
|
|
|
|
}
|
2015-03-27 19:11:44 +00:00
|
|
|
if (target->getCanvas() &&
|
|
|
|
kUnknown_SkColorType == target->getCanvas()->imageInfo().colorType()) {
|
2014-08-07 21:28:50 +00:00
|
|
|
return false;
|
|
|
|
}
|
2015-03-26 18:28:06 +00:00
|
|
|
|
2014-08-07 21:28:50 +00:00
|
|
|
SkBitmap bmp;
|
2015-03-26 18:28:06 +00:00
|
|
|
|
|
|
|
if (!target->capturePixels(&bmp)) {
|
2014-08-07 21:28:50 +00:00
|
|
|
return false;
|
|
|
|
}
|
2015-03-26 18:28:06 +00:00
|
|
|
|
2014-08-07 21:28:50 +00:00
|
|
|
SkString dir = SkOSPath::Dirname(filename.c_str());
|
|
|
|
if (!sk_mkdir(dir.c_str())) {
|
|
|
|
SkDebugf("Can't make dir %s.\n", dir.c_str());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
SkFILEWStream stream(filename.c_str());
|
|
|
|
if (!stream.isValid()) {
|
|
|
|
SkDebugf("Can't write %s.\n", filename.c_str());
|
|
|
|
return false;
|
|
|
|
}
|
2016-11-23 15:55:18 +00:00
|
|
|
if (!SkEncodeImage(&stream, bmp, SkEncodedImageFormat::kPNG, 100)) {
|
2014-08-07 21:28:50 +00:00
|
|
|
SkDebugf("Can't encode a PNG.\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int kFailedLoops = -2;
|
2015-06-26 02:17:08 +00:00
|
|
|
static int setup_cpu_bench(const double overhead, Target* target, Benchmark* bench) {
|
2014-07-01 15:43:42 +00:00
|
|
|
// First figure out approximately how many loops of bench it takes to make overhead negligible.
|
2014-08-04 20:57:39 +00:00
|
|
|
double bench_plus_overhead = 0.0;
|
2014-07-17 15:38:23 +00:00
|
|
|
int round = 0;
|
2015-06-25 17:51:56 +00:00
|
|
|
int loops = bench->calculateLoops(FLAGS_loops);
|
|
|
|
if (kAutoTuneLoops == loops) {
|
2014-08-07 21:28:50 +00:00
|
|
|
while (bench_plus_overhead < overhead) {
|
|
|
|
if (round++ == FLAGS_maxCalibrationAttempts) {
|
|
|
|
SkDebugf("WARNING: Can't estimate loops for %s (%s vs. %s); skipping.\n",
|
2014-09-10 19:05:59 +00:00
|
|
|
bench->getUniqueName(), HUMANIZE(bench_plus_overhead), HUMANIZE(overhead));
|
2014-08-07 21:28:50 +00:00
|
|
|
return kFailedLoops;
|
|
|
|
}
|
2015-03-27 19:11:44 +00:00
|
|
|
bench_plus_overhead = time(1, bench, target);
|
2014-07-17 15:38:23 +00:00
|
|
|
}
|
2014-08-04 20:57:39 +00:00
|
|
|
}
|
2014-06-25 21:08:00 +00:00
|
|
|
|
2014-07-01 15:43:42 +00:00
|
|
|
// Later we'll just start and stop the timer once but loop N times.
|
2014-06-25 21:08:00 +00:00
|
|
|
// We'll pick N to make timer overhead negligible:
|
|
|
|
//
|
2014-07-01 15:43:42 +00:00
|
|
|
// overhead
|
|
|
|
// ------------------------- < FLAGS_overheadGoal
|
|
|
|
// overhead + N * Bench Time
|
2014-06-25 21:08:00 +00:00
|
|
|
//
|
2017-01-03 15:36:17 +00:00
|
|
|
// where bench_plus_overhead ~=~ overhead + Bench Time.
|
2014-06-25 21:08:00 +00:00
|
|
|
//
|
|
|
|
// Doing some math, we get:
|
|
|
|
//
|
2014-07-01 15:43:42 +00:00
|
|
|
// (overhead / FLAGS_overheadGoal) - overhead
|
|
|
|
// ------------------------------------------ < N
|
|
|
|
// bench_plus_overhead - overhead)
|
2014-06-25 21:08:00 +00:00
|
|
|
//
|
|
|
|
// Luckily, this also works well in practice. :)
|
2014-08-07 21:28:50 +00:00
|
|
|
if (kAutoTuneLoops == loops) {
|
|
|
|
const double numer = overhead / FLAGS_overheadGoal - overhead;
|
|
|
|
const double denom = bench_plus_overhead - overhead;
|
|
|
|
loops = (int)ceil(numer / denom);
|
2014-10-10 16:09:52 +00:00
|
|
|
loops = clamp_loops(loops);
|
|
|
|
} else {
|
|
|
|
loops = detect_forever_loops(loops);
|
2014-08-07 21:28:50 +00:00
|
|
|
}
|
2014-07-01 15:43:42 +00:00
|
|
|
|
|
|
|
return loops;
|
2014-06-25 21:08:00 +00:00
|
|
|
}
|
|
|
|
|
2015-06-26 02:17:08 +00:00
|
|
|
static int setup_gpu_bench(Target* target, Benchmark* bench, int maxGpuFrameLag) {
|
2014-07-01 15:43:42 +00:00
|
|
|
// First, figure out how many loops it'll take to get a frame up to FLAGS_gpuMs.
|
2015-06-25 17:51:56 +00:00
|
|
|
int loops = bench->calculateLoops(FLAGS_loops);
|
2014-08-07 21:28:50 +00:00
|
|
|
if (kAutoTuneLoops == loops) {
|
|
|
|
loops = 1;
|
2014-07-14 19:28:47 +00:00
|
|
|
double elapsed = 0;
|
|
|
|
do {
|
2014-11-06 16:04:34 +00:00
|
|
|
if (1<<30 == loops) {
|
|
|
|
// We're about to wrap. Something's wrong with the bench.
|
|
|
|
loops = 0;
|
|
|
|
break;
|
|
|
|
}
|
2014-07-14 19:28:47 +00:00
|
|
|
loops *= 2;
|
|
|
|
// If the GPU lets frames lag at all, we need to make sure we're timing
|
2015-06-23 20:23:44 +00:00
|
|
|
// _this_ round, not still timing last round.
|
|
|
|
for (int i = 0; i < maxGpuFrameLag; i++) {
|
2015-03-27 19:11:44 +00:00
|
|
|
elapsed = time(loops, bench, target);
|
2014-07-14 19:28:47 +00:00
|
|
|
}
|
|
|
|
} while (elapsed < FLAGS_gpuMs);
|
|
|
|
|
|
|
|
// We've overshot at least a little. Scale back linearly.
|
|
|
|
loops = (int)ceil(loops * FLAGS_gpuMs / elapsed);
|
2014-10-10 16:09:52 +00:00
|
|
|
loops = clamp_loops(loops);
|
2014-07-14 19:28:47 +00:00
|
|
|
|
2015-03-26 18:28:06 +00:00
|
|
|
// Make sure we're not still timing our calibration.
|
|
|
|
target->fence();
|
2014-10-10 16:09:52 +00:00
|
|
|
} else {
|
|
|
|
loops = detect_forever_loops(loops);
|
2014-07-14 19:28:47 +00:00
|
|
|
}
|
2014-07-01 15:43:42 +00:00
|
|
|
// Pretty much the same deal as the calibration: do some warmup to make
|
|
|
|
// sure we're timing steady-state pipelined frames.
|
2017-10-10 19:41:03 +00:00
|
|
|
for (int i = 0; i < maxGpuFrameLag; i++) {
|
2015-03-27 19:11:44 +00:00
|
|
|
time(loops, bench, target);
|
2014-06-25 21:08:00 +00:00
|
|
|
}
|
2014-07-01 15:43:42 +00:00
|
|
|
|
|
|
|
return loops;
|
2014-06-25 21:08:00 +00:00
|
|
|
}
|
2014-07-01 15:43:42 +00:00
|
|
|
|
2017-03-20 12:54:16 +00:00
|
|
|
#define kBogusContextType GrContextFactory::kGL_ContextType
|
2017-02-21 19:36:05 +00:00
|
|
|
#define kBogusContextOverrides GrContextFactory::ContextOverrides::kNone
|
2014-07-22 20:09:05 +00:00
|
|
|
|
2016-01-28 14:05:43 +00:00
|
|
|
static void create_config(const SkCommandLineConfig* config, SkTArray<Config>* configs) {
|
|
|
|
if (const auto* gpuConfig = config->asConfigGpu()) {
|
2017-08-11 01:25:55 +00:00
|
|
|
if (!FLAGS_gpu) {
|
|
|
|
SkDebugf("Skipping config '%s' as requested.\n", config->getTag().c_str());
|
2016-01-28 14:05:43 +00:00
|
|
|
return;
|
2017-08-11 01:25:55 +00:00
|
|
|
}
|
2016-01-28 14:05:43 +00:00
|
|
|
|
|
|
|
const auto ctxType = gpuConfig->getContextType();
|
2017-02-21 19:36:05 +00:00
|
|
|
const auto ctxOverrides = gpuConfig->getContextOverrides();
|
2016-01-28 14:05:43 +00:00
|
|
|
const auto sampleCount = gpuConfig->getSamples();
|
2017-07-19 18:47:42 +00:00
|
|
|
const auto colorType = gpuConfig->getColorType();
|
|
|
|
auto colorSpace = gpuConfig->getColorSpace();
|
2018-03-09 14:01:53 +00:00
|
|
|
if (gpuConfig->getSurfType() != SkCommandLineConfigGpu::SurfType::kDefault) {
|
|
|
|
SkDebugf("This tool only supports the default surface type.");
|
|
|
|
return;
|
|
|
|
}
|
2016-01-28 14:05:43 +00:00
|
|
|
|
2017-10-11 19:34:27 +00:00
|
|
|
GrContextFactory factory(grContextOpts);
|
2020-07-06 17:45:34 +00:00
|
|
|
if (const auto ctx = factory.get(ctxType, ctxOverrides)) {
|
2019-08-07 19:52:37 +00:00
|
|
|
GrBackendFormat format = ctx->defaultBackendFormat(colorType, GrRenderable::kYes);
|
2018-02-03 01:32:49 +00:00
|
|
|
int supportedSampleCount =
|
2019-08-07 19:52:37 +00:00
|
|
|
ctx->priv().caps()->getRenderTargetSampleCount(sampleCount, format);
|
2017-07-19 18:47:42 +00:00
|
|
|
if (sampleCount != supportedSampleCount) {
|
2017-08-11 01:25:55 +00:00
|
|
|
SkDebugf("Configuration '%s' sample count %d is not a supported sample count.\n",
|
|
|
|
config->getTag().c_str(), sampleCount);
|
2016-01-28 14:05:43 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
2017-08-11 01:25:55 +00:00
|
|
|
SkDebugf("No context was available matching config '%s'.\n",
|
|
|
|
config->getTag().c_str());
|
2016-01-28 14:05:43 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Config target = {
|
2016-03-02 07:41:26 +00:00
|
|
|
gpuConfig->getTag(),
|
2016-01-28 14:05:43 +00:00
|
|
|
Benchmark::kGPU_Backend,
|
2017-07-19 18:47:42 +00:00
|
|
|
colorType,
|
2016-01-28 14:05:43 +00:00
|
|
|
kPremul_SkAlphaType,
|
2017-07-19 18:47:42 +00:00
|
|
|
sk_ref_sp(colorSpace),
|
2016-01-28 14:05:43 +00:00
|
|
|
sampleCount,
|
|
|
|
ctxType,
|
2017-02-21 19:36:05 +00:00
|
|
|
ctxOverrides,
|
2021-03-17 02:49:15 +00:00
|
|
|
gpuConfig->getSurfaceFlags()
|
2016-03-02 07:41:26 +00:00
|
|
|
};
|
2016-01-28 14:05:43 +00:00
|
|
|
|
|
|
|
configs->push_back(target);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-06-16 20:03:24 +00:00
|
|
|
#define CPU_CONFIG(name, backend, color, alpha, colorSpace) \
|
|
|
|
if (config->getTag().equals(#name)) { \
|
2017-08-11 01:25:55 +00:00
|
|
|
if (!FLAGS_cpu) { \
|
|
|
|
SkDebugf("Skipping config '%s' as requested.\n", \
|
|
|
|
config->getTag().c_str()); \
|
|
|
|
return; \
|
|
|
|
} \
|
2016-06-16 20:03:24 +00:00
|
|
|
Config config = { \
|
|
|
|
SkString(#name), Benchmark::backend, color, alpha, colorSpace, \
|
2021-04-19 23:40:40 +00:00
|
|
|
0, kBogusContextType, kBogusContextOverrides, 0 \
|
2016-06-16 20:03:24 +00:00
|
|
|
}; \
|
|
|
|
configs->push_back(config); \
|
|
|
|
return; \
|
2014-06-25 21:08:00 +00:00
|
|
|
}
|
2014-07-31 19:13:48 +00:00
|
|
|
|
2017-08-11 01:25:55 +00:00
|
|
|
CPU_CONFIG(nonrendering, kNonRendering_Backend,
|
|
|
|
kUnknown_SkColorType, kUnpremul_SkAlphaType, nullptr)
|
|
|
|
|
2018-06-19 20:00:40 +00:00
|
|
|
CPU_CONFIG(a8, kRaster_Backend, kAlpha_8_SkColorType, kPremul_SkAlphaType, nullptr)
|
|
|
|
CPU_CONFIG(8888, kRaster_Backend, kN32_SkColorType, kPremul_SkAlphaType, nullptr)
|
|
|
|
CPU_CONFIG(565, kRaster_Backend, kRGB_565_SkColorType, kOpaque_SkAlphaType, nullptr)
|
|
|
|
|
|
|
|
// 'narrow' has a gamut narrower than sRGB, and different transfer function.
|
2019-01-04 22:03:00 +00:00
|
|
|
auto narrow = SkColorSpace::MakeRGB(SkNamedTransferFn::k2Dot2, gNarrow_toXYZD50),
|
2018-06-19 20:00:40 +00:00
|
|
|
srgb = SkColorSpace::MakeSRGB(),
|
|
|
|
srgbLinear = SkColorSpace::MakeSRGBLinear();
|
|
|
|
|
|
|
|
CPU_CONFIG( f16, kRaster_Backend, kRGBA_F16_SkColorType, kPremul_SkAlphaType, srgbLinear)
|
|
|
|
CPU_CONFIG( srgb, kRaster_Backend, kRGBA_8888_SkColorType, kPremul_SkAlphaType, srgb )
|
|
|
|
CPU_CONFIG( esrgb, kRaster_Backend, kRGBA_F16_SkColorType, kPremul_SkAlphaType, srgb )
|
|
|
|
CPU_CONFIG( narrow, kRaster_Backend, kRGBA_8888_SkColorType, kPremul_SkAlphaType, narrow )
|
|
|
|
CPU_CONFIG(enarrow, kRaster_Backend, kRGBA_F16_SkColorType, kPremul_SkAlphaType, narrow )
|
2014-06-25 21:08:00 +00:00
|
|
|
|
2016-01-28 14:05:43 +00:00
|
|
|
#undef CPU_CONFIG
|
2017-08-11 01:25:55 +00:00
|
|
|
|
|
|
|
SkDebugf("Unknown config '%s'.\n", config->getTag().c_str());
|
2014-06-25 21:08:00 +00:00
|
|
|
}
|
|
|
|
|
2016-01-28 14:05:43 +00:00
|
|
|
// Append all configs that are enabled and supported.
|
|
|
|
void create_configs(SkTArray<Config>* configs) {
|
|
|
|
SkCommandLineConfigArray array;
|
|
|
|
ParseConfigs(FLAGS_config, &array);
|
|
|
|
for (int i = 0; i < array.count(); ++i) {
|
2016-11-03 18:40:50 +00:00
|
|
|
create_config(array[i].get(), configs);
|
2016-01-28 14:05:43 +00:00
|
|
|
}
|
2017-08-11 01:25:55 +00:00
|
|
|
|
|
|
|
// If no just default configs were requested, then we're okay.
|
|
|
|
if (array.count() == 0 || FLAGS_config.count() == 0 ||
|
|
|
|
// Otherwise, make sure that all specified configs have been created.
|
|
|
|
array.count() == configs->count()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
exit(1);
|
2016-01-28 14:05:43 +00:00
|
|
|
}
|
|
|
|
|
2016-09-15 15:33:02 +00:00
|
|
|
// disable warning : switch statement contains default but no 'case' labels
|
|
|
|
#if defined _WIN32
|
|
|
|
#pragma warning ( push )
|
|
|
|
#pragma warning ( disable : 4065 )
|
|
|
|
#endif
|
|
|
|
|
2015-08-27 14:41:13 +00:00
|
|
|
// If bench is enabled for config, returns a Target* for it, otherwise nullptr.
|
2014-07-22 20:09:05 +00:00
|
|
|
static Target* is_enabled(Benchmark* bench, const Config& config) {
|
|
|
|
if (!bench->isSuitableFor(config.backend)) {
|
2015-08-27 14:41:13 +00:00
|
|
|
return nullptr;
|
2014-07-22 20:09:05 +00:00
|
|
|
}
|
|
|
|
|
2014-09-03 18:54:58 +00:00
|
|
|
SkImageInfo info = SkImageInfo::Make(bench->getSize().fX, bench->getSize().fY,
|
2016-06-16 20:03:24 +00:00
|
|
|
config.color, config.alpha, config.colorSpace);
|
2014-07-22 20:09:05 +00:00
|
|
|
|
2015-08-27 14:41:13 +00:00
|
|
|
Target* target = nullptr;
|
2014-07-22 20:09:05 +00:00
|
|
|
|
2015-03-26 18:28:06 +00:00
|
|
|
switch (config.backend) {
|
|
|
|
case Benchmark::kGPU_Backend:
|
|
|
|
target = new GPUTarget(config);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
target = new Target(config);
|
|
|
|
break;
|
|
|
|
}
|
2014-07-22 20:09:05 +00:00
|
|
|
|
2015-03-26 18:28:06 +00:00
|
|
|
if (!target->init(info, bench)) {
|
2014-07-22 20:09:05 +00:00
|
|
|
delete target;
|
2015-08-27 14:41:13 +00:00
|
|
|
return nullptr;
|
2014-07-22 20:09:05 +00:00
|
|
|
}
|
|
|
|
return target;
|
|
|
|
}
|
|
|
|
|
2016-09-15 15:33:02 +00:00
|
|
|
#if defined _WIN32
|
|
|
|
#pragma warning ( pop )
|
|
|
|
#endif
|
|
|
|
|
2020-05-04 14:02:45 +00:00
|
|
|
#ifdef SK_ENABLE_ANDROID_UTILS
|
2016-09-12 19:01:44 +00:00
|
|
|
static bool valid_brd_bench(sk_sp<SkData> encoded, SkColorType colorType, uint32_t sampleSize,
|
2016-05-18 13:23:57 +00:00
|
|
|
uint32_t minOutputSize, int* width, int* height) {
|
2020-05-04 14:02:45 +00:00
|
|
|
auto brd = android::skia::BitmapRegionDecoder::Make(encoded);
|
2020-08-16 12:48:02 +00:00
|
|
|
if (nullptr == brd) {
|
2015-09-22 18:56:16 +00:00
|
|
|
// This is indicates that subset decoding is not supported for a particular image format.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sampleSize * minOutputSize > (uint32_t) brd->width() || sampleSize * minOutputSize >
|
|
|
|
(uint32_t) brd->height()) {
|
|
|
|
// This indicates that the image is not large enough to decode a
|
|
|
|
// minOutputSize x minOutputSize subset at the given sampleSize.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set the image width and height. The calling code will use this to choose subsets to decode.
|
|
|
|
*width = brd->width();
|
|
|
|
*height = brd->height();
|
|
|
|
return true;
|
|
|
|
}
|
2020-05-04 14:02:45 +00:00
|
|
|
#endif
|
2015-09-22 18:56:16 +00:00
|
|
|
|
2015-06-26 15:12:46 +00:00
|
|
|
static void cleanup_run(Target* target) {
|
2015-08-26 20:07:48 +00:00
|
|
|
delete target;
|
2015-06-26 15:12:46 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 15:50:33 +00:00
|
|
|
static void collect_files(const CommandLineFlags::StringArray& paths,
|
|
|
|
const char* ext,
|
|
|
|
SkTArray<SkString>* list) {
|
2016-09-14 15:05:17 +00:00
|
|
|
for (int i = 0; i < paths.count(); ++i) {
|
|
|
|
if (SkStrEndsWith(paths[i], ext)) {
|
|
|
|
list->push_back(SkString(paths[i]));
|
|
|
|
} else {
|
|
|
|
SkOSFile::Iter it(paths[i], ext);
|
|
|
|
SkString path;
|
|
|
|
while (it.next(&path)) {
|
|
|
|
list->push_back(SkOSPath::Join(paths[i], path.c_str()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-31 19:13:48 +00:00
|
|
|
class BenchmarkStream {
|
|
|
|
public:
|
2014-08-01 14:46:52 +00:00
|
|
|
BenchmarkStream() : fBenches(BenchRegistry::Head())
|
2019-10-24 17:40:40 +00:00
|
|
|
, fGMs(skiagm::GMRegistry::Head()) {
|
2016-09-14 15:05:17 +00:00
|
|
|
collect_files(FLAGS_skps, ".skp", &fSKPs);
|
2021-04-30 17:08:55 +00:00
|
|
|
collect_files(FLAGS_mskps, ".mskp", &fMSKPs);
|
2016-09-14 15:05:17 +00:00
|
|
|
collect_files(FLAGS_svgs, ".svg", &fSVGs);
|
2019-10-24 17:52:17 +00:00
|
|
|
collect_files(FLAGS_texttraces, ".trace", &fTextBlobTraces);
|
2014-08-01 14:46:52 +00:00
|
|
|
|
|
|
|
if (4 != sscanf(FLAGS_clip[0], "%d,%d,%d,%d",
|
|
|
|
&fClip.fLeft, &fClip.fTop, &fClip.fRight, &fClip.fBottom)) {
|
|
|
|
SkDebugf("Can't parse %s from --clip as an SkIRect.\n", FLAGS_clip[0]);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < FLAGS_scales.count(); i++) {
|
|
|
|
if (1 != sscanf(FLAGS_scales[i], "%f", &fScales.push_back())) {
|
|
|
|
SkDebugf("Can't parse %s from --scales as an SkScalar.\n", FLAGS_scales[i]);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
2014-11-21 14:19:36 +00:00
|
|
|
|
2015-06-29 21:06:10 +00:00
|
|
|
if (2 != sscanf(FLAGS_zoom[0], "%f,%lf", &fZoomMax, &fZoomPeriodMs)) {
|
|
|
|
SkDebugf("Can't parse %s from --zoom as a zoomMax,zoomPeriodMs.\n", FLAGS_zoom[0]);
|
2015-04-27 16:16:57 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2015-02-13 17:05:41 +00:00
|
|
|
// Prepare the images for decoding
|
2016-04-29 16:38:40 +00:00
|
|
|
if (!CollectImages(FLAGS_images, &fImages)) {
|
2016-02-03 20:19:11 +00:00
|
|
|
exit(1);
|
2015-02-13 17:05:41 +00:00
|
|
|
}
|
2015-03-12 15:24:21 +00:00
|
|
|
|
2015-02-13 17:05:41 +00:00
|
|
|
// Choose the candidate color types for image decoding
|
2016-06-21 15:49:26 +00:00
|
|
|
fColorTypes.push_back(kN32_SkColorType);
|
|
|
|
if (!FLAGS_simpleCodec) {
|
|
|
|
fColorTypes.push_back(kRGB_565_SkColorType);
|
|
|
|
fColorTypes.push_back(kAlpha_8_SkColorType);
|
|
|
|
fColorTypes.push_back(kGray_8_SkColorType);
|
|
|
|
}
|
2014-08-01 14:46:52 +00:00
|
|
|
}
|
2014-07-31 19:13:48 +00:00
|
|
|
|
2016-03-18 14:25:55 +00:00
|
|
|
static sk_sp<SkPicture> ReadPicture(const char* path) {
|
2014-09-10 19:19:30 +00:00
|
|
|
// Not strictly necessary, as it will be checked again later,
|
|
|
|
// but helps to avoid a lot of pointless work if we're going to skip it.
|
2019-03-20 15:50:33 +00:00
|
|
|
if (CommandLineFlags::ShouldSkip(FLAGS_match, SkOSPath::Basename(path).c_str())) {
|
2016-03-18 14:25:55 +00:00
|
|
|
return nullptr;
|
2014-09-10 19:19:30 +00:00
|
|
|
}
|
|
|
|
|
2016-09-16 13:24:20 +00:00
|
|
|
std::unique_ptr<SkStream> stream = SkStream::MakeFromFile(path);
|
|
|
|
if (!stream) {
|
2014-09-10 19:19:30 +00:00
|
|
|
SkDebugf("Could not read %s.\n", path);
|
2016-03-18 14:25:55 +00:00
|
|
|
return nullptr;
|
2014-09-10 19:19:30 +00:00
|
|
|
}
|
|
|
|
|
2016-03-18 14:25:55 +00:00
|
|
|
return SkPicture::MakeFromStream(stream.get());
|
2014-09-10 19:19:30 +00:00
|
|
|
}
|
|
|
|
|
2021-04-30 17:08:55 +00:00
|
|
|
static std::unique_ptr<MSKPPlayer> ReadMSKP(const char* path) {
|
|
|
|
// Not strictly necessary, as it will be checked again later,
|
|
|
|
// but helps to avoid a lot of pointless work if we're going to skip it.
|
|
|
|
if (CommandLineFlags::ShouldSkip(FLAGS_match, SkOSPath::Basename(path).c_str())) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<SkStreamSeekable> stream = SkStream::MakeFromFile(path);
|
|
|
|
if (!stream) {
|
|
|
|
SkDebugf("Could not read %s.\n", path);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return MSKPPlayer::Make(stream.get());
|
|
|
|
}
|
|
|
|
|
2016-09-14 15:05:17 +00:00
|
|
|
static sk_sp<SkPicture> ReadSVGPicture(const char* path) {
|
2020-12-04 15:20:32 +00:00
|
|
|
if (CommandLineFlags::ShouldSkip(FLAGS_match, SkOSPath::Basename(path).c_str())) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2018-09-19 18:14:15 +00:00
|
|
|
sk_sp<SkData> data(SkData::MakeFromFileName(path));
|
|
|
|
if (!data) {
|
2016-09-14 15:05:17 +00:00
|
|
|
SkDebugf("Could not read %s.\n", path);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2018-03-22 19:21:12 +00:00
|
|
|
#ifdef SK_XML
|
2018-09-19 18:14:15 +00:00
|
|
|
SkMemoryStream stream(std::move(data));
|
2016-09-14 19:04:30 +00:00
|
|
|
sk_sp<SkSVGDOM> svgDom = SkSVGDOM::MakeFromStream(stream);
|
2016-09-14 15:05:17 +00:00
|
|
|
if (!svgDom) {
|
|
|
|
SkDebugf("Could not parse %s.\n", path);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2016-09-14 19:04:30 +00:00
|
|
|
// Use the intrinsic SVG size if available, otherwise fall back to a default value.
|
|
|
|
static const SkSize kDefaultContainerSize = SkSize::Make(128, 128);
|
|
|
|
if (svgDom->containerSize().isEmpty()) {
|
|
|
|
svgDom->setContainerSize(kDefaultContainerSize);
|
|
|
|
}
|
|
|
|
|
2016-09-14 15:05:17 +00:00
|
|
|
SkPictureRecorder recorder;
|
2016-09-14 19:04:30 +00:00
|
|
|
svgDom->render(recorder.beginRecording(svgDom->containerSize().width(),
|
|
|
|
svgDom->containerSize().height()));
|
2016-09-14 15:05:17 +00:00
|
|
|
return recorder.finishRecordingAsPicture();
|
2018-03-22 19:21:12 +00:00
|
|
|
#else
|
|
|
|
return nullptr;
|
|
|
|
#endif // SK_XML
|
2016-09-14 15:05:17 +00:00
|
|
|
}
|
|
|
|
|
2014-08-01 14:46:52 +00:00
|
|
|
Benchmark* next() {
|
2016-11-03 18:40:50 +00:00
|
|
|
std::unique_ptr<Benchmark> bench;
|
2016-02-03 18:40:54 +00:00
|
|
|
do {
|
|
|
|
bench.reset(this->rawNext());
|
|
|
|
if (!bench) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2019-03-20 15:50:33 +00:00
|
|
|
} while (CommandLineFlags::ShouldSkip(FLAGS_sourceType, fSourceType) ||
|
|
|
|
CommandLineFlags::ShouldSkip(FLAGS_benchType, fBenchType));
|
2016-03-16 20:53:35 +00:00
|
|
|
return bench.release();
|
2016-02-03 18:40:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Benchmark* rawNext() {
|
2014-07-31 19:13:48 +00:00
|
|
|
if (fBenches) {
|
2018-07-30 21:07:07 +00:00
|
|
|
Benchmark* bench = fBenches->get()(nullptr);
|
2014-07-31 19:13:48 +00:00
|
|
|
fBenches = fBenches->next();
|
2014-08-01 14:46:52 +00:00
|
|
|
fSourceType = "bench";
|
2014-09-10 19:19:30 +00:00
|
|
|
fBenchType = "micro";
|
2014-07-31 19:13:48 +00:00
|
|
|
return bench;
|
|
|
|
}
|
2014-08-01 14:46:52 +00:00
|
|
|
|
2014-07-31 19:13:48 +00:00
|
|
|
while (fGMs) {
|
2019-08-12 20:39:24 +00:00
|
|
|
std::unique_ptr<skiagm::GM> gm = fGMs->get()();
|
2014-07-31 19:13:48 +00:00
|
|
|
fGMs = fGMs->next();
|
2015-01-23 18:31:45 +00:00
|
|
|
if (gm->runAsBench()) {
|
2014-08-01 14:46:52 +00:00
|
|
|
fSourceType = "gm";
|
2014-09-10 19:19:30 +00:00
|
|
|
fBenchType = "micro";
|
2019-08-12 20:39:24 +00:00
|
|
|
return new GMBench(std::move(gm));
|
2014-07-31 19:13:48 +00:00
|
|
|
}
|
|
|
|
}
|
2014-08-01 14:46:52 +00:00
|
|
|
|
2019-10-24 17:52:17 +00:00
|
|
|
while (fCurrentTextBlobTrace < fTextBlobTraces.count()) {
|
|
|
|
SkString path = fTextBlobTraces[fCurrentTextBlobTrace++];
|
|
|
|
SkString basename = SkOSPath::Basename(path.c_str());
|
|
|
|
static constexpr char kEnding[] = ".trace";
|
|
|
|
if (basename.endsWith(kEnding)) {
|
|
|
|
basename.remove(basename.size() - strlen(kEnding), strlen(kEnding));
|
|
|
|
}
|
|
|
|
fSourceType = "texttrace";
|
|
|
|
fBenchType = "micro";
|
|
|
|
return CreateDiffCanvasBench(
|
|
|
|
SkStringPrintf("SkDiffBench-%s", basename.c_str()),
|
|
|
|
[path](){ return SkStream::MakeFromFile(path.c_str()); });
|
|
|
|
}
|
|
|
|
|
2014-09-10 19:19:30 +00:00
|
|
|
// First add all .skps as RecordingBenches.
|
|
|
|
while (fCurrentRecording < fSKPs.count()) {
|
|
|
|
const SkString& path = fSKPs[fCurrentRecording++];
|
2016-03-18 14:25:55 +00:00
|
|
|
sk_sp<SkPicture> pic = ReadPicture(path.c_str());
|
|
|
|
if (!pic) {
|
2014-09-10 19:19:30 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
SkString name = SkOSPath::Basename(path.c_str());
|
|
|
|
fSourceType = "skp";
|
|
|
|
fBenchType = "recording";
|
2018-01-27 17:30:04 +00:00
|
|
|
fSKPBytes = static_cast<double>(pic->approximateBytesUsed());
|
|
|
|
fSKPOps = pic->approximateOpCount();
|
2019-05-14 17:33:40 +00:00
|
|
|
return new RecordingBench(name.c_str(), pic.get(), FLAGS_bbh);
|
2014-09-10 19:19:30 +00:00
|
|
|
}
|
|
|
|
|
2017-12-06 15:47:03 +00:00
|
|
|
// Add all .skps as DeserializePictureBenchs.
|
|
|
|
while (fCurrentDeserialPicture < fSKPs.count()) {
|
|
|
|
const SkString& path = fSKPs[fCurrentDeserialPicture++];
|
|
|
|
sk_sp<SkData> data = SkData::MakeFromFileName(path.c_str());
|
|
|
|
if (!data) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
SkString name = SkOSPath::Basename(path.c_str());
|
|
|
|
fSourceType = "skp";
|
|
|
|
fBenchType = "deserial";
|
2017-12-25 00:50:57 +00:00
|
|
|
fSKPBytes = static_cast<double>(data->size());
|
2018-01-27 17:30:04 +00:00
|
|
|
fSKPOps = 0;
|
2017-12-06 15:47:03 +00:00
|
|
|
return new DeserializePictureBench(name.c_str(), std::move(data));
|
|
|
|
}
|
|
|
|
|
2014-09-10 19:19:30 +00:00
|
|
|
// Then once each for each scale as SKPBenches (playback).
|
2014-08-01 14:46:52 +00:00
|
|
|
while (fCurrentScale < fScales.count()) {
|
|
|
|
while (fCurrentSKP < fSKPs.count()) {
|
2020-08-27 14:54:36 +00:00
|
|
|
const SkString& path = fSKPs[fCurrentSKP++];
|
2016-03-18 14:25:55 +00:00
|
|
|
sk_sp<SkPicture> pic = ReadPicture(path.c_str());
|
|
|
|
if (!pic) {
|
2014-08-01 14:46:52 +00:00
|
|
|
continue;
|
|
|
|
}
|
2014-11-21 14:19:36 +00:00
|
|
|
|
2020-08-27 14:54:36 +00:00
|
|
|
if (FLAGS_bbh) {
|
|
|
|
// The SKP we read off disk doesn't have a BBH. Re-record so it grows one.
|
|
|
|
SkRTreeFactory factory;
|
|
|
|
SkPictureRecorder recorder;
|
|
|
|
pic->playback(recorder.beginRecording(pic->cullRect().width(),
|
|
|
|
pic->cullRect().height(),
|
|
|
|
&factory));
|
|
|
|
pic = recorder.finishRecordingAsPicture();
|
Add --bbh (default true) to nanobench.
Chrome's using a bounding box, so it's a good idea for our
bots to do so too.
When set, we'll create an SkTileGrid to match the
parameters of --clip, and so should always hit its fast
path.
This will impose a small overhead (querying the BBH) on all
SKPs, but make large SKPs render more quickly. E.g. on
GPU desk_pokemonwiki should show about a 30% improvement,
tabl_mozilla about 40%, and one very long page from my
personal suite, askmefast.com, gets 5x faster.
(The performance changes are not the point of the CL, but
something we should be aware of.)
BUG=
R=bsalomon@google.com, mtklein@google.com, robertphillips@google.com
Author: mtklein@chromium.org
Review URL: https://codereview.chromium.org/497493003
2014-08-21 22:51:22 +00:00
|
|
|
}
|
2020-08-27 14:54:36 +00:00
|
|
|
SkString name = SkOSPath::Basename(path.c_str());
|
|
|
|
fSourceType = "skp";
|
|
|
|
fBenchType = "playback";
|
|
|
|
return new SKPBench(name.c_str(), pic.get(), fClip, fScales[fCurrentScale],
|
|
|
|
FLAGS_loopSKP);
|
2014-08-01 14:46:52 +00:00
|
|
|
}
|
2016-09-14 15:05:17 +00:00
|
|
|
|
2020-08-27 14:54:36 +00:00
|
|
|
while (fCurrentSVG < fSVGs.count()) {
|
|
|
|
const char* path = fSVGs[fCurrentSVG++].c_str();
|
2016-09-14 15:05:17 +00:00
|
|
|
if (sk_sp<SkPicture> pic = ReadSVGPicture(path)) {
|
|
|
|
fSourceType = "svg";
|
|
|
|
fBenchType = "playback";
|
|
|
|
return new SKPBench(SkOSPath::Basename(path).c_str(), pic.get(), fClip,
|
2020-08-27 14:54:36 +00:00
|
|
|
fScales[fCurrentScale], FLAGS_loopSKP);
|
2016-09-14 15:05:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-01 14:46:52 +00:00
|
|
|
fCurrentSKP = 0;
|
2016-09-14 15:05:17 +00:00
|
|
|
fCurrentSVG = 0;
|
2014-08-01 14:46:52 +00:00
|
|
|
fCurrentScale++;
|
|
|
|
}
|
|
|
|
|
2015-04-27 16:16:57 +00:00
|
|
|
// Now loop over each skp again if we have an animation
|
2015-06-29 21:06:10 +00:00
|
|
|
if (fZoomMax != 1.0f && fZoomPeriodMs > 0) {
|
2015-04-27 16:16:57 +00:00
|
|
|
while (fCurrentAnimSKP < fSKPs.count()) {
|
|
|
|
const SkString& path = fSKPs[fCurrentAnimSKP];
|
2016-03-18 14:25:55 +00:00
|
|
|
sk_sp<SkPicture> pic = ReadPicture(path.c_str());
|
|
|
|
if (!pic) {
|
2015-04-27 16:16:57 +00:00
|
|
|
fCurrentAnimSKP++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
fCurrentAnimSKP++;
|
|
|
|
SkString name = SkOSPath::Basename(path.c_str());
|
2019-07-12 16:51:44 +00:00
|
|
|
sk_sp<SKPAnimationBench::Animation> animation =
|
|
|
|
SKPAnimationBench::MakeZoomAnimation(fZoomMax, fZoomPeriodMs);
|
|
|
|
return new SKPAnimationBench(name.c_str(), pic.get(), fClip, std::move(animation),
|
2015-08-26 20:07:48 +00:00
|
|
|
FLAGS_loopSKP);
|
2015-04-27 16:16:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-30 17:08:55 +00:00
|
|
|
// Read all MSKPs as benches
|
|
|
|
while (fCurrentMSKP < fMSKPs.count()) {
|
|
|
|
const SkString& path = fMSKPs[fCurrentMSKP++];
|
|
|
|
std::unique_ptr<MSKPPlayer> player = ReadMSKP(path.c_str());
|
|
|
|
if (!player) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
SkString name = SkOSPath::Basename(path.c_str());
|
|
|
|
fSourceType = "mskp";
|
|
|
|
fBenchType = "mskp";
|
|
|
|
return new MSKPBench(std::move(name), std::move(player));
|
|
|
|
}
|
|
|
|
|
2015-04-01 19:09:17 +00:00
|
|
|
for (; fCurrentCodec < fImages.count(); fCurrentCodec++) {
|
2015-10-05 18:03:34 +00:00
|
|
|
fSourceType = "image";
|
|
|
|
fBenchType = "skcodec";
|
2015-04-01 19:09:17 +00:00
|
|
|
const SkString& path = fImages[fCurrentCodec];
|
2019-03-20 15:50:33 +00:00
|
|
|
if (CommandLineFlags::ShouldSkip(FLAGS_match, path.c_str())) {
|
2016-01-11 17:04:21 +00:00
|
|
|
continue;
|
|
|
|
}
|
2016-08-02 21:40:46 +00:00
|
|
|
sk_sp<SkData> encoded(SkData::MakeFromFileName(path.c_str()));
|
2017-07-23 19:30:02 +00:00
|
|
|
std::unique_ptr<SkCodec> codec(SkCodec::MakeFromData(encoded));
|
2015-04-01 19:09:17 +00:00
|
|
|
if (!codec) {
|
|
|
|
// Nothing to time.
|
2015-04-24 18:41:55 +00:00
|
|
|
SkDebugf("Cannot find codec for %s\n", path.c_str());
|
2015-04-01 19:09:17 +00:00
|
|
|
continue;
|
|
|
|
}
|
2015-04-02 20:22:38 +00:00
|
|
|
|
2015-04-01 19:09:17 +00:00
|
|
|
while (fCurrentColorType < fColorTypes.count()) {
|
2015-04-02 20:22:38 +00:00
|
|
|
const SkColorType colorType = fColorTypes[fCurrentColorType];
|
|
|
|
|
2016-01-07 22:20:20 +00:00
|
|
|
SkAlphaType alphaType = codec->getInfo().alphaType();
|
2016-06-21 15:49:26 +00:00
|
|
|
if (FLAGS_simpleCodec) {
|
|
|
|
if (kUnpremul_SkAlphaType == alphaType) {
|
|
|
|
alphaType = kPremul_SkAlphaType;
|
|
|
|
}
|
|
|
|
|
|
|
|
fCurrentColorType++;
|
|
|
|
} else {
|
|
|
|
switch (alphaType) {
|
|
|
|
case kOpaque_SkAlphaType:
|
|
|
|
// We only need to test one alpha type (opaque).
|
2016-01-07 22:20:20 +00:00
|
|
|
fCurrentColorType++;
|
2016-06-21 15:49:26 +00:00
|
|
|
break;
|
|
|
|
case kUnpremul_SkAlphaType:
|
|
|
|
case kPremul_SkAlphaType:
|
|
|
|
if (0 == fCurrentAlphaType) {
|
|
|
|
// Test unpremul first.
|
|
|
|
alphaType = kUnpremul_SkAlphaType;
|
|
|
|
fCurrentAlphaType++;
|
|
|
|
} else {
|
|
|
|
// Test premul.
|
|
|
|
alphaType = kPremul_SkAlphaType;
|
|
|
|
fCurrentAlphaType = 0;
|
|
|
|
fCurrentColorType++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
SkASSERT(false);
|
|
|
|
fCurrentColorType++;
|
|
|
|
break;
|
|
|
|
}
|
2015-04-02 20:22:38 +00:00
|
|
|
}
|
|
|
|
|
2016-01-07 22:20:20 +00:00
|
|
|
// Make sure we can decode to this color type and alpha type.
|
|
|
|
SkImageInfo info =
|
|
|
|
codec->getInfo().makeColorType(colorType).makeAlphaType(alphaType);
|
2015-04-02 20:22:38 +00:00
|
|
|
const size_t rowBytes = info.minRowBytes();
|
2017-10-03 18:47:21 +00:00
|
|
|
SkAutoMalloc storage(info.computeByteSize(rowBytes));
|
2015-04-02 20:22:38 +00:00
|
|
|
|
SkCodec no longer inherits from SkImageGenerator.
SkImageGenerator makes some assumptions that are not necessarily valid
for SkCodec. For example, SkCodec does not assume that it can always be
rewound.
We also have an ongoing question of what an SkCodec should report as
its default settings (i.e. the return from getInfo). It makes sense for
an SkCodec to report that its pixels are unpremultiplied, if that is
the case for the underlying data, but if a client of SkImageGenerator
uses the default settings (as many do), they will receive
unpremultiplied pixels which cannot (currently) be drawn with Skia. We
may ultimately decide to revisit SkCodec reporting an SkImageInfo, but
I have left it unchanged for now.
Import features of SkImageGenerator used by SkCodec into SkCodec.
I have left SkImageGenerator unchanged for now, but it no longer needs
Result or Options. This will require changes to Chromium.
Manually handle the lifetime of fScanlineDecoder, so SkScanlineDecoder.h
can include SkCodec.h (where Result is), and SkCodec.h does not need
to include it (to delete fScanlineDecoder).
In many places, make the following simple changes:
- Now include SkScanlineDecoder.h, which is no longer included by
SkCodec.h
- Use the enums in SkCodec, rather than SkImageGenerator
- Stop including SkImageGenerator.h where no longer needed
Review URL: https://codereview.chromium.org/1220733013
2015-07-09 15:16:03 +00:00
|
|
|
const SkCodec::Result result = codec->getPixels(
|
2017-07-11 17:35:31 +00:00
|
|
|
info, storage.get(), rowBytes);
|
2015-04-01 19:09:17 +00:00
|
|
|
switch (result) {
|
SkCodec no longer inherits from SkImageGenerator.
SkImageGenerator makes some assumptions that are not necessarily valid
for SkCodec. For example, SkCodec does not assume that it can always be
rewound.
We also have an ongoing question of what an SkCodec should report as
its default settings (i.e. the return from getInfo). It makes sense for
an SkCodec to report that its pixels are unpremultiplied, if that is
the case for the underlying data, but if a client of SkImageGenerator
uses the default settings (as many do), they will receive
unpremultiplied pixels which cannot (currently) be drawn with Skia. We
may ultimately decide to revisit SkCodec reporting an SkImageInfo, but
I have left it unchanged for now.
Import features of SkImageGenerator used by SkCodec into SkCodec.
I have left SkImageGenerator unchanged for now, but it no longer needs
Result or Options. This will require changes to Chromium.
Manually handle the lifetime of fScanlineDecoder, so SkScanlineDecoder.h
can include SkCodec.h (where Result is), and SkCodec.h does not need
to include it (to delete fScanlineDecoder).
In many places, make the following simple changes:
- Now include SkScanlineDecoder.h, which is no longer included by
SkCodec.h
- Use the enums in SkCodec, rather than SkImageGenerator
- Stop including SkImageGenerator.h where no longer needed
Review URL: https://codereview.chromium.org/1220733013
2015-07-09 15:16:03 +00:00
|
|
|
case SkCodec::kSuccess:
|
|
|
|
case SkCodec::kIncompleteInput:
|
2015-04-01 19:09:17 +00:00
|
|
|
return new CodecBench(SkOSPath::Basename(path.c_str()),
|
2016-08-02 21:40:46 +00:00
|
|
|
encoded.get(), colorType, alphaType);
|
SkCodec no longer inherits from SkImageGenerator.
SkImageGenerator makes some assumptions that are not necessarily valid
for SkCodec. For example, SkCodec does not assume that it can always be
rewound.
We also have an ongoing question of what an SkCodec should report as
its default settings (i.e. the return from getInfo). It makes sense for
an SkCodec to report that its pixels are unpremultiplied, if that is
the case for the underlying data, but if a client of SkImageGenerator
uses the default settings (as many do), they will receive
unpremultiplied pixels which cannot (currently) be drawn with Skia. We
may ultimately decide to revisit SkCodec reporting an SkImageInfo, but
I have left it unchanged for now.
Import features of SkImageGenerator used by SkCodec into SkCodec.
I have left SkImageGenerator unchanged for now, but it no longer needs
Result or Options. This will require changes to Chromium.
Manually handle the lifetime of fScanlineDecoder, so SkScanlineDecoder.h
can include SkCodec.h (where Result is), and SkCodec.h does not need
to include it (to delete fScanlineDecoder).
In many places, make the following simple changes:
- Now include SkScanlineDecoder.h, which is no longer included by
SkCodec.h
- Use the enums in SkCodec, rather than SkImageGenerator
- Stop including SkImageGenerator.h where no longer needed
Review URL: https://codereview.chromium.org/1220733013
2015-07-09 15:16:03 +00:00
|
|
|
case SkCodec::kInvalidConversion:
|
2015-04-01 19:09:17 +00:00
|
|
|
// This is okay. Not all conversions are valid.
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// This represents some sort of failure.
|
|
|
|
SkASSERT(false);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fCurrentColorType = 0;
|
|
|
|
}
|
|
|
|
|
2016-02-11 14:45:51 +00:00
|
|
|
// Run AndroidCodecBenches
|
|
|
|
const int sampleSizes[] = { 2, 4, 8 };
|
|
|
|
for (; fCurrentAndroidCodec < fImages.count(); fCurrentAndroidCodec++) {
|
|
|
|
fSourceType = "image";
|
|
|
|
fBenchType = "skandroidcodec";
|
|
|
|
|
|
|
|
const SkString& path = fImages[fCurrentAndroidCodec];
|
2019-03-20 15:50:33 +00:00
|
|
|
if (CommandLineFlags::ShouldSkip(FLAGS_match, path.c_str())) {
|
2016-02-11 14:45:51 +00:00
|
|
|
continue;
|
|
|
|
}
|
2016-08-02 21:40:46 +00:00
|
|
|
sk_sp<SkData> encoded(SkData::MakeFromFileName(path.c_str()));
|
2017-07-23 19:30:02 +00:00
|
|
|
std::unique_ptr<SkAndroidCodec> codec(SkAndroidCodec::MakeFromData(encoded));
|
2016-02-11 14:45:51 +00:00
|
|
|
if (!codec) {
|
|
|
|
// Nothing to time.
|
|
|
|
SkDebugf("Cannot find codec for %s\n", path.c_str());
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (fCurrentSampleSize < (int) SK_ARRAY_COUNT(sampleSizes)) {
|
|
|
|
int sampleSize = sampleSizes[fCurrentSampleSize];
|
|
|
|
fCurrentSampleSize++;
|
2020-02-07 15:36:46 +00:00
|
|
|
if (10 * sampleSize > std::min(codec->getInfo().width(), codec->getInfo().height())) {
|
2016-02-11 14:45:51 +00:00
|
|
|
// Avoid benchmarking scaled decodes of already small images.
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-08-02 21:40:46 +00:00
|
|
|
return new AndroidCodecBench(SkOSPath::Basename(path.c_str()),
|
|
|
|
encoded.get(), sampleSize);
|
2016-02-11 14:45:51 +00:00
|
|
|
}
|
|
|
|
fCurrentSampleSize = 0;
|
|
|
|
}
|
|
|
|
|
2020-05-04 14:02:45 +00:00
|
|
|
#ifdef SK_ENABLE_ANDROID_UTILS
|
2015-09-22 18:56:16 +00:00
|
|
|
// Run the BRDBenches
|
|
|
|
// We intend to create benchmarks that model the use cases in
|
|
|
|
// android/libraries/social/tiledimage. In this library, an image is decoded in 512x512
|
|
|
|
// tiles. The image can be translated freely, so the location of a tile may be anywhere in
|
|
|
|
// the image. For that reason, we will benchmark decodes in five representative locations
|
|
|
|
// in the image. Additionally, this use case utilizes power of two scaling, so we will
|
|
|
|
// test on power of two sample sizes. The output tile is always 512x512, so, when a
|
|
|
|
// sampleSize is used, the size of the subset that is decoded is always
|
|
|
|
// (sampleSize*512)x(sampleSize*512).
|
|
|
|
// There are a few good reasons to only test on power of two sample sizes at this time:
|
|
|
|
// All use cases we are aware of only scale by powers of two.
|
|
|
|
// PNG decodes use the indicated sampling strategy regardless of the sample size, so
|
|
|
|
// these tests are sufficient to provide good coverage of our scaling options.
|
2016-02-11 14:45:51 +00:00
|
|
|
const uint32_t brdSampleSizes[] = { 1, 2, 4, 8, 16 };
|
2015-09-22 18:56:16 +00:00
|
|
|
const uint32_t minOutputSize = 512;
|
2016-01-11 17:04:21 +00:00
|
|
|
for (; fCurrentBRDImage < fImages.count(); fCurrentBRDImage++) {
|
2016-05-18 13:23:57 +00:00
|
|
|
fSourceType = "image";
|
|
|
|
fBenchType = "BRD";
|
|
|
|
|
2016-01-11 17:04:21 +00:00
|
|
|
const SkString& path = fImages[fCurrentBRDImage];
|
2019-03-20 15:50:33 +00:00
|
|
|
if (CommandLineFlags::ShouldSkip(FLAGS_match, path.c_str())) {
|
2016-01-11 17:04:21 +00:00
|
|
|
continue;
|
|
|
|
}
|
2016-05-18 13:23:57 +00:00
|
|
|
|
|
|
|
while (fCurrentColorType < fColorTypes.count()) {
|
|
|
|
while (fCurrentSampleSize < (int) SK_ARRAY_COUNT(brdSampleSizes)) {
|
|
|
|
while (fCurrentSubsetType <= kLastSingle_SubsetType) {
|
|
|
|
|
2016-08-02 21:40:46 +00:00
|
|
|
sk_sp<SkData> encoded(SkData::MakeFromFileName(path.c_str()));
|
2016-05-18 13:23:57 +00:00
|
|
|
const SkColorType colorType = fColorTypes[fCurrentColorType];
|
|
|
|
uint32_t sampleSize = brdSampleSizes[fCurrentSampleSize];
|
|
|
|
int currentSubsetType = fCurrentSubsetType++;
|
|
|
|
|
|
|
|
int width = 0;
|
|
|
|
int height = 0;
|
2016-09-12 19:01:44 +00:00
|
|
|
if (!valid_brd_bench(encoded, colorType, sampleSize, minOutputSize,
|
2016-05-18 13:23:57 +00:00
|
|
|
&width, &height)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
SkString basename = SkOSPath::Basename(path.c_str());
|
|
|
|
SkIRect subset;
|
|
|
|
const uint32_t subsetSize = sampleSize * minOutputSize;
|
|
|
|
switch (currentSubsetType) {
|
|
|
|
case kTopLeft_SubsetType:
|
|
|
|
basename.append("_TopLeft");
|
|
|
|
subset = SkIRect::MakeXYWH(0, 0, subsetSize, subsetSize);
|
|
|
|
break;
|
|
|
|
case kTopRight_SubsetType:
|
|
|
|
basename.append("_TopRight");
|
|
|
|
subset = SkIRect::MakeXYWH(width - subsetSize, 0, subsetSize,
|
|
|
|
subsetSize);
|
|
|
|
break;
|
|
|
|
case kMiddle_SubsetType:
|
|
|
|
basename.append("_Middle");
|
|
|
|
subset = SkIRect::MakeXYWH((width - subsetSize) / 2,
|
|
|
|
(height - subsetSize) / 2, subsetSize, subsetSize);
|
2015-09-22 18:56:16 +00:00
|
|
|
break;
|
2016-05-18 13:23:57 +00:00
|
|
|
case kBottomLeft_SubsetType:
|
|
|
|
basename.append("_BottomLeft");
|
|
|
|
subset = SkIRect::MakeXYWH(0, height - subsetSize, subsetSize,
|
|
|
|
subsetSize);
|
|
|
|
break;
|
|
|
|
case kBottomRight_SubsetType:
|
|
|
|
basename.append("_BottomRight");
|
|
|
|
subset = SkIRect::MakeXYWH(width - subsetSize,
|
|
|
|
height - subsetSize, subsetSize, subsetSize);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
SkASSERT(false);
|
2015-09-22 18:56:16 +00:00
|
|
|
}
|
2016-05-18 13:23:57 +00:00
|
|
|
|
|
|
|
return new BitmapRegionDecoderBench(basename.c_str(), encoded.get(),
|
|
|
|
colorType, sampleSize, subset);
|
2015-09-22 18:56:16 +00:00
|
|
|
}
|
2016-05-18 13:23:57 +00:00
|
|
|
fCurrentSubsetType = 0;
|
|
|
|
fCurrentSampleSize++;
|
2015-09-22 18:56:16 +00:00
|
|
|
}
|
2016-05-18 13:23:57 +00:00
|
|
|
fCurrentSampleSize = 0;
|
|
|
|
fCurrentColorType++;
|
2015-09-22 18:56:16 +00:00
|
|
|
}
|
2016-05-18 13:23:57 +00:00
|
|
|
fCurrentColorType = 0;
|
2015-09-22 18:56:16 +00:00
|
|
|
}
|
2020-05-04 14:02:45 +00:00
|
|
|
#endif // SK_ENABLE_ANDROID_UTILS
|
2015-09-22 18:56:16 +00:00
|
|
|
|
2015-08-27 14:41:13 +00:00
|
|
|
return nullptr;
|
2014-07-31 19:13:48 +00:00
|
|
|
}
|
2014-08-01 14:46:52 +00:00
|
|
|
|
2019-01-28 19:24:29 +00:00
|
|
|
void fillCurrentOptions(NanoJSONResultsWriter& log) const {
|
|
|
|
log.appendString("source_type", fSourceType);
|
|
|
|
log.appendString("bench_type", fBenchType);
|
2014-08-01 14:46:52 +00:00
|
|
|
if (0 == strcmp(fSourceType, "skp")) {
|
2019-01-28 19:24:29 +00:00
|
|
|
log.appendString("clip",
|
2014-08-01 14:46:52 +00:00
|
|
|
SkStringPrintf("%d %d %d %d", fClip.fLeft, fClip.fTop,
|
|
|
|
fClip.fRight, fClip.fBottom).c_str());
|
2016-01-29 16:51:04 +00:00
|
|
|
SkASSERT_RELEASE(fCurrentScale < fScales.count()); // debugging paranoia
|
2019-01-28 19:24:29 +00:00
|
|
|
log.appendString("scale", SkStringPrintf("%.2g", fScales[fCurrentScale]).c_str());
|
2014-08-01 14:46:52 +00:00
|
|
|
}
|
2019-01-28 19:24:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void fillCurrentMetrics(NanoJSONResultsWriter& log) const {
|
Upload picture byte size and op count metrics for SKP recording.
Look okay?
{
"results" : {
"desk_amazon.skp_1264_3999" : {
"nonrendering" : {
"bytes" : 75656,
"max_ms" : 1.150187,
"mean_ms" : 1.150187,
"median_ms" : 1.150187,
"min_ms" : 1.150187,
"ops" : 659,
"options" : {
"bench_type" : "recording",
"clip" : "0 0 1000 1000",
"name" : "desk_amazon.skp",
"scale" : "1",
"source_type" : "skp"
}
}
},
...
BUG=skia:
Review URL: https://codereview.chromium.org/773323002
2014-12-04 16:46:51 +00:00
|
|
|
if (0 == strcmp(fBenchType, "recording")) {
|
2019-01-28 19:24:29 +00:00
|
|
|
log.appendMetric("bytes", fSKPBytes);
|
|
|
|
log.appendMetric("ops", fSKPOps);
|
Upload picture byte size and op count metrics for SKP recording.
Look okay?
{
"results" : {
"desk_amazon.skp_1264_3999" : {
"nonrendering" : {
"bytes" : 75656,
"max_ms" : 1.150187,
"mean_ms" : 1.150187,
"median_ms" : 1.150187,
"min_ms" : 1.150187,
"ops" : 659,
"options" : {
"bench_type" : "recording",
"clip" : "0 0 1000 1000",
"name" : "desk_amazon.skp",
"scale" : "1",
"source_type" : "skp"
}
}
},
...
BUG=skia:
Review URL: https://codereview.chromium.org/773323002
2014-12-04 16:46:51 +00:00
|
|
|
}
|
2014-08-01 14:46:52 +00:00
|
|
|
}
|
|
|
|
|
2014-07-31 19:13:48 +00:00
|
|
|
private:
|
2020-05-04 14:02:45 +00:00
|
|
|
#ifdef SK_ENABLE_ANDROID_UTILS
|
2015-06-09 20:56:10 +00:00
|
|
|
enum SubsetType {
|
|
|
|
kTopLeft_SubsetType = 0,
|
|
|
|
kTopRight_SubsetType = 1,
|
2015-06-17 17:28:22 +00:00
|
|
|
kMiddle_SubsetType = 2,
|
|
|
|
kBottomLeft_SubsetType = 3,
|
|
|
|
kBottomRight_SubsetType = 4,
|
|
|
|
kTranslate_SubsetType = 5,
|
|
|
|
kZoom_SubsetType = 6,
|
2015-09-22 18:56:16 +00:00
|
|
|
kLast_SubsetType = kZoom_SubsetType,
|
|
|
|
kLastSingle_SubsetType = kBottomRight_SubsetType,
|
2015-06-09 20:56:10 +00:00
|
|
|
};
|
2020-05-04 14:02:45 +00:00
|
|
|
#endif
|
2015-06-09 20:56:10 +00:00
|
|
|
|
2014-07-31 19:13:48 +00:00
|
|
|
const BenchRegistry* fBenches;
|
|
|
|
const skiagm::GMRegistry* fGMs;
|
2014-08-01 14:46:52 +00:00
|
|
|
SkIRect fClip;
|
|
|
|
SkTArray<SkScalar> fScales;
|
|
|
|
SkTArray<SkString> fSKPs;
|
2021-04-30 17:08:55 +00:00
|
|
|
SkTArray<SkString> fMSKPs;
|
2016-09-14 15:05:17 +00:00
|
|
|
SkTArray<SkString> fSVGs;
|
2019-10-24 17:52:17 +00:00
|
|
|
SkTArray<SkString> fTextBlobTraces;
|
2015-02-13 17:05:41 +00:00
|
|
|
SkTArray<SkString> fImages;
|
2015-10-20 23:45:56 +00:00
|
|
|
SkTArray<SkColorType, true> fColorTypes;
|
2015-06-29 21:06:10 +00:00
|
|
|
SkScalar fZoomMax;
|
|
|
|
double fZoomPeriodMs;
|
2014-08-01 14:46:52 +00:00
|
|
|
|
2018-01-27 17:30:04 +00:00
|
|
|
double fSKPBytes, fSKPOps;
|
Upload picture byte size and op count metrics for SKP recording.
Look okay?
{
"results" : {
"desk_amazon.skp_1264_3999" : {
"nonrendering" : {
"bytes" : 75656,
"max_ms" : 1.150187,
"mean_ms" : 1.150187,
"median_ms" : 1.150187,
"min_ms" : 1.150187,
"ops" : 659,
"options" : {
"bench_type" : "recording",
"clip" : "0 0 1000 1000",
"name" : "desk_amazon.skp",
"scale" : "1",
"source_type" : "skp"
}
}
},
...
BUG=skia:
Review URL: https://codereview.chromium.org/773323002
2014-12-04 16:46:51 +00:00
|
|
|
|
2014-09-10 19:19:30 +00:00
|
|
|
const char* fSourceType; // What we're benching: bench, GM, SKP, ...
|
|
|
|
const char* fBenchType; // How we bench it: micro, recording, playback, ...
|
2019-10-24 17:40:40 +00:00
|
|
|
int fCurrentRecording = 0;
|
|
|
|
int fCurrentDeserialPicture = 0;
|
2021-04-30 17:08:55 +00:00
|
|
|
int fCurrentMSKP = 0;
|
2019-10-24 17:40:40 +00:00
|
|
|
int fCurrentScale = 0;
|
|
|
|
int fCurrentSKP = 0;
|
|
|
|
int fCurrentSVG = 0;
|
2019-10-24 17:52:17 +00:00
|
|
|
int fCurrentTextBlobTrace = 0;
|
2019-10-24 17:40:40 +00:00
|
|
|
int fCurrentCodec = 0;
|
|
|
|
int fCurrentAndroidCodec = 0;
|
2020-05-04 14:02:45 +00:00
|
|
|
#ifdef SK_ENABLE_ANDROID_UTILS
|
2019-10-24 17:40:40 +00:00
|
|
|
int fCurrentBRDImage = 0;
|
2020-05-04 14:02:45 +00:00
|
|
|
int fCurrentSubsetType = 0;
|
|
|
|
#endif
|
2019-10-24 17:40:40 +00:00
|
|
|
int fCurrentColorType = 0;
|
|
|
|
int fCurrentAlphaType = 0;
|
|
|
|
int fCurrentSampleSize = 0;
|
|
|
|
int fCurrentAnimSKP = 0;
|
2014-07-31 19:13:48 +00:00
|
|
|
};
|
|
|
|
|
2016-01-04 19:35:43 +00:00
|
|
|
// Some runs (mostly, Valgrind) are so slow that the bot framework thinks we've hung.
|
|
|
|
// This prints something every once in a while so that it knows we're still working.
|
|
|
|
static void start_keepalive() {
|
2017-10-30 15:57:15 +00:00
|
|
|
static std::thread* intentionallyLeaked = new std::thread([]{
|
|
|
|
for (;;) {
|
|
|
|
static const int kSec = 1200;
|
|
|
|
#if defined(SK_BUILD_FOR_WIN)
|
|
|
|
Sleep(kSec * 1000);
|
|
|
|
#else
|
|
|
|
sleep(kSec);
|
|
|
|
#endif
|
|
|
|
SkDebugf("\nBenchmarks still running...\n");
|
2016-01-04 19:35:43 +00:00
|
|
|
}
|
2017-10-30 15:57:15 +00:00
|
|
|
});
|
|
|
|
(void)intentionallyLeaked;
|
2016-01-04 19:35:43 +00:00
|
|
|
}
|
|
|
|
|
2021-03-23 14:25:02 +00:00
|
|
|
class NanobenchShaderErrorHandler : public GrContextOptions::ShaderErrorHandler {
|
|
|
|
void compileError(const char* shader, const char* errors) override {
|
|
|
|
// Nanobench should abort if any shader can't compile. Failure is much better than
|
|
|
|
// reporting meaningless performance metrics.
|
|
|
|
SkSL::String message = GrShaderUtils::BuildShaderErrorMessage(shader, errors);
|
2021-03-23 14:25:15 +00:00
|
|
|
SK_ABORT("\n%s", message.c_str());
|
2021-03-23 14:25:02 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-02-06 17:46:20 +00:00
|
|
|
int main(int argc, char** argv) {
|
2019-03-20 15:50:33 +00:00
|
|
|
CommandLineFlags::Parse(argc, argv);
|
2017-07-20 19:43:35 +00:00
|
|
|
|
2017-07-24 15:38:01 +00:00
|
|
|
initializeEventTracingForTools();
|
2017-07-20 19:43:35 +00:00
|
|
|
|
2017-02-06 14:26:14 +00:00
|
|
|
#if defined(SK_BUILD_FOR_IOS)
|
|
|
|
cd_Documents();
|
|
|
|
#endif
|
2014-11-13 16:06:40 +00:00
|
|
|
SetupCrashHandler();
|
2014-06-25 21:08:00 +00:00
|
|
|
SkAutoGraphics ag;
|
2015-07-09 17:04:56 +00:00
|
|
|
SkTaskGroup::Enabler enabled(FLAGS_threads);
|
2014-06-25 21:08:00 +00:00
|
|
|
|
2017-12-18 21:22:34 +00:00
|
|
|
SetCtxOptionsFromCommonFlags(&grContextOpts);
|
2014-08-13 17:46:31 +00:00
|
|
|
|
2021-03-23 14:25:02 +00:00
|
|
|
NanobenchShaderErrorHandler errorHandler;
|
|
|
|
grContextOpts.fShaderErrorHandler = &errorHandler;
|
|
|
|
|
2014-08-07 21:28:50 +00:00
|
|
|
if (kAutoTuneLoops != FLAGS_loops) {
|
2014-07-14 19:28:47 +00:00
|
|
|
FLAGS_samples = 1;
|
|
|
|
FLAGS_gpuFrameLag = 0;
|
|
|
|
}
|
|
|
|
|
2014-08-07 21:28:50 +00:00
|
|
|
if (!FLAGS_writePath.isEmpty()) {
|
|
|
|
SkDebugf("Writing files to %s.\n", FLAGS_writePath[0]);
|
|
|
|
if (!sk_mkdir(FLAGS_writePath[0])) {
|
|
|
|
SkDebugf("Could not create %s. Files won't be written.\n", FLAGS_writePath[0]);
|
2015-08-27 14:41:13 +00:00
|
|
|
FLAGS_writePath.set(0, nullptr);
|
2014-08-07 21:28:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-28 19:24:29 +00:00
|
|
|
std::unique_ptr<SkWStream> logStream(new SkNullWStream);
|
2014-07-14 18:30:37 +00:00
|
|
|
if (!FLAGS_outResultsFile.isEmpty()) {
|
2016-01-20 17:53:59 +00:00
|
|
|
#if defined(SK_RELEASE)
|
2019-10-23 20:35:19 +00:00
|
|
|
// SkJSONWriter uses a 32k in-memory cache, so it only flushes occasionally and is well
|
|
|
|
// equipped for a stream that re-opens, appends, and closes the file on every write.
|
|
|
|
logStream.reset(new NanoFILEAppendAndCloseStream(FLAGS_outResultsFile[0]));
|
2016-01-20 17:53:59 +00:00
|
|
|
#else
|
|
|
|
SkDebugf("I'm ignoring --outResultsFile because this is a Debug build.");
|
|
|
|
return 1;
|
|
|
|
#endif
|
2014-07-14 18:30:37 +00:00
|
|
|
}
|
2019-01-28 19:24:29 +00:00
|
|
|
NanoJSONResultsWriter log(logStream.get(), SkJSONWriter::Mode::kPretty);
|
|
|
|
log.beginObject(); // root
|
2014-07-17 20:14:16 +00:00
|
|
|
|
2014-08-20 18:45:00 +00:00
|
|
|
if (1 == FLAGS_properties.count() % 2) {
|
|
|
|
SkDebugf("ERROR: --properties must be passed with an even number of arguments.\n");
|
2014-07-17 20:14:16 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2014-08-20 18:45:00 +00:00
|
|
|
for (int i = 1; i < FLAGS_properties.count(); i += 2) {
|
2019-01-28 19:24:29 +00:00
|
|
|
log.appendString(FLAGS_properties[i-1], FLAGS_properties[i]);
|
2014-07-17 20:14:16 +00:00
|
|
|
}
|
Add --options to nanobench, similar to --key but for non-identifying options.
Friends with https://codereview.chromium.org/487233003/
Example of out/Release/nanobench --options build_number 12374 --match patch_grid_texs_small
{
"gitHash":"unknown-revision",
"options":{
"build_number":"12374",
"system":"UNIX"
},
"results":{
"patch_grid_texs_small_640_480":{
"565":{
"max_ms":0.268116,
"mean_ms":0.2318529,
"median_ms":0.235337,
"min_ms":0.219158,
"options":{
"source_type":"bench"
},
"stddev_ms":0.01491263917658814
},
"8888":{
"max_ms":0.231881,
"mean_ms":0.2214668,
"median_ms":0.219356,
"min_ms":0.218887,
"options":{
"source_type":"bench"
},
"stddev_ms":0.004595541070791701
},
"gpu":{
"max_ms":0.1398304782608696,
"mean_ms":0.128833402173913,
"median_ms":0.1316798695652174,
"min_ms":0.1111915434782609,
"options":{
"GL_RENDERER":"Quadro 600/PCIe/SSE2",
"GL_SHADING_LANGUAGE_VERSION":"4.40 NVIDIA via Cg compiler",
"GL_VENDOR":"NVIDIA Corporation",
"GL_VERSION":"4.4.0 NVIDIA 331.79",
"source_type":"bench"
},
"stddev_ms":0.008923738937837156
}
}
}
}
BUG=skia:
R=jcgregorio@google.com, mtklein@google.com
Author: mtklein@chromium.org
Review URL: https://codereview.chromium.org/490683002
2014-08-19 19:41:53 +00:00
|
|
|
|
2014-08-20 18:45:00 +00:00
|
|
|
if (1 == FLAGS_key.count() % 2) {
|
|
|
|
SkDebugf("ERROR: --key must be passed with an even number of arguments.\n");
|
Add --options to nanobench, similar to --key but for non-identifying options.
Friends with https://codereview.chromium.org/487233003/
Example of out/Release/nanobench --options build_number 12374 --match patch_grid_texs_small
{
"gitHash":"unknown-revision",
"options":{
"build_number":"12374",
"system":"UNIX"
},
"results":{
"patch_grid_texs_small_640_480":{
"565":{
"max_ms":0.268116,
"mean_ms":0.2318529,
"median_ms":0.235337,
"min_ms":0.219158,
"options":{
"source_type":"bench"
},
"stddev_ms":0.01491263917658814
},
"8888":{
"max_ms":0.231881,
"mean_ms":0.2214668,
"median_ms":0.219356,
"min_ms":0.218887,
"options":{
"source_type":"bench"
},
"stddev_ms":0.004595541070791701
},
"gpu":{
"max_ms":0.1398304782608696,
"mean_ms":0.128833402173913,
"median_ms":0.1316798695652174,
"min_ms":0.1111915434782609,
"options":{
"GL_RENDERER":"Quadro 600/PCIe/SSE2",
"GL_SHADING_LANGUAGE_VERSION":"4.40 NVIDIA via Cg compiler",
"GL_VENDOR":"NVIDIA Corporation",
"GL_VERSION":"4.4.0 NVIDIA 331.79",
"source_type":"bench"
},
"stddev_ms":0.008923738937837156
}
}
}
}
BUG=skia:
R=jcgregorio@google.com, mtklein@google.com
Author: mtklein@chromium.org
Review URL: https://codereview.chromium.org/490683002
2014-08-19 19:41:53 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2019-01-28 19:24:29 +00:00
|
|
|
if (FLAGS_key.count()) {
|
|
|
|
log.beginObject("key");
|
|
|
|
for (int i = 1; i < FLAGS_key.count(); i += 2) {
|
|
|
|
log.appendString(FLAGS_key[i - 1], FLAGS_key[i]);
|
|
|
|
}
|
|
|
|
log.endObject(); // key
|
Add --options to nanobench, similar to --key but for non-identifying options.
Friends with https://codereview.chromium.org/487233003/
Example of out/Release/nanobench --options build_number 12374 --match patch_grid_texs_small
{
"gitHash":"unknown-revision",
"options":{
"build_number":"12374",
"system":"UNIX"
},
"results":{
"patch_grid_texs_small_640_480":{
"565":{
"max_ms":0.268116,
"mean_ms":0.2318529,
"median_ms":0.235337,
"min_ms":0.219158,
"options":{
"source_type":"bench"
},
"stddev_ms":0.01491263917658814
},
"8888":{
"max_ms":0.231881,
"mean_ms":0.2214668,
"median_ms":0.219356,
"min_ms":0.218887,
"options":{
"source_type":"bench"
},
"stddev_ms":0.004595541070791701
},
"gpu":{
"max_ms":0.1398304782608696,
"mean_ms":0.128833402173913,
"median_ms":0.1316798695652174,
"min_ms":0.1111915434782609,
"options":{
"GL_RENDERER":"Quadro 600/PCIe/SSE2",
"GL_SHADING_LANGUAGE_VERSION":"4.40 NVIDIA via Cg compiler",
"GL_VENDOR":"NVIDIA Corporation",
"GL_VERSION":"4.4.0 NVIDIA 331.79",
"source_type":"bench"
},
"stddev_ms":0.008923738937837156
}
}
}
}
BUG=skia:
R=jcgregorio@google.com, mtklein@google.com
Author: mtklein@chromium.org
Review URL: https://codereview.chromium.org/490683002
2014-08-19 19:41:53 +00:00
|
|
|
}
|
2014-07-14 18:30:37 +00:00
|
|
|
|
2014-06-25 21:08:00 +00:00
|
|
|
const double overhead = estimate_timer_overhead();
|
2014-07-17 15:38:23 +00:00
|
|
|
SkDebugf("Timer overhead: %s\n", HUMANIZE(overhead));
|
2014-07-16 23:59:32 +00:00
|
|
|
|
2015-06-26 02:17:08 +00:00
|
|
|
SkTArray<double> samples;
|
2014-07-01 15:43:42 +00:00
|
|
|
|
2014-08-07 21:28:50 +00:00
|
|
|
if (kAutoTuneLoops != FLAGS_loops) {
|
|
|
|
SkDebugf("Fixed number of loops; times would only be misleading so we won't print them.\n");
|
2014-06-25 21:08:00 +00:00
|
|
|
} else if (FLAGS_quiet) {
|
2015-12-04 14:35:30 +00:00
|
|
|
SkDebugf("! -> high variance, ? -> moderate variance\n");
|
|
|
|
SkDebugf(" micros \tbench\n");
|
2015-10-28 18:36:30 +00:00
|
|
|
} else if (FLAGS_ms) {
|
2015-06-26 02:17:08 +00:00
|
|
|
SkDebugf("curr/maxrss\tloops\tmin\tmedian\tmean\tmax\tstddev\tsamples\tconfig\tbench\n");
|
2014-06-25 21:08:00 +00:00
|
|
|
} else {
|
2015-04-30 14:11:22 +00:00
|
|
|
SkDebugf("curr/maxrss\tloops\tmin\tmedian\tmean\tmax\tstddev\t%-*s\tconfig\tbench\n",
|
2014-09-10 02:24:36 +00:00
|
|
|
FLAGS_samples, "samples");
|
2014-06-25 21:08:00 +00:00
|
|
|
}
|
|
|
|
|
2021-04-30 23:16:12 +00:00
|
|
|
GrRecordingContextPriv::DMSAAStats combinedDMSAAStats;
|
|
|
|
|
2016-01-28 14:05:43 +00:00
|
|
|
SkTArray<Config> configs;
|
2014-07-22 20:09:05 +00:00
|
|
|
create_configs(&configs);
|
|
|
|
|
2016-01-04 19:35:43 +00:00
|
|
|
if (FLAGS_keepAlive) {
|
|
|
|
start_keepalive();
|
|
|
|
}
|
|
|
|
|
2019-03-22 16:39:09 +00:00
|
|
|
SetAnalyticAAFromCommonFlags();
|
2016-10-04 18:23:22 +00:00
|
|
|
|
2020-08-05 14:33:38 +00:00
|
|
|
gSkForceRasterPipelineBlitter = FLAGS_forceRasterPipeline;
|
|
|
|
gUseSkVMBlitter = FLAGS_skvm;
|
2021-03-23 19:32:45 +00:00
|
|
|
gSkVMAllowJIT = FLAGS_jit;
|
|
|
|
gSkVMJITViaDylib = FLAGS_dylib;
|
2017-01-13 15:13:13 +00:00
|
|
|
|
2014-10-14 15:40:43 +00:00
|
|
|
int runs = 0;
|
2014-08-01 14:46:52 +00:00
|
|
|
BenchmarkStream benchStream;
|
2019-01-28 19:24:29 +00:00
|
|
|
log.beginObject("results");
|
2019-05-31 14:49:12 +00:00
|
|
|
AutoreleasePool pool;
|
2014-08-01 14:46:52 +00:00
|
|
|
while (Benchmark* b = benchStream.next()) {
|
2016-11-03 18:40:50 +00:00
|
|
|
std::unique_ptr<Benchmark> bench(b);
|
2019-03-20 15:50:33 +00:00
|
|
|
if (CommandLineFlags::ShouldSkip(FLAGS_match, bench->getUniqueName())) {
|
2014-06-25 21:08:00 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-01-28 14:05:43 +00:00
|
|
|
if (!configs.empty()) {
|
2019-01-28 19:24:29 +00:00
|
|
|
log.beginBench(bench->getUniqueName(), bench->getSize().fX, bench->getSize().fY);
|
2015-09-30 19:11:07 +00:00
|
|
|
bench->delayedSetup();
|
2014-07-17 20:14:16 +00:00
|
|
|
}
|
2015-06-26 15:12:46 +00:00
|
|
|
for (int i = 0; i < configs.count(); ++i) {
|
|
|
|
Target* target = is_enabled(b, configs[i]);
|
|
|
|
if (!target) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2015-08-27 14:41:13 +00:00
|
|
|
// During HWUI output this canvas may be nullptr.
|
2015-06-26 15:12:46 +00:00
|
|
|
SkCanvas* canvas = target->getCanvas();
|
2016-01-28 14:05:43 +00:00
|
|
|
const char* config = target->config.name.c_str();
|
2014-07-01 15:43:42 +00:00
|
|
|
|
2016-02-08 21:49:12 +00:00
|
|
|
if (FLAGS_pre_log || FLAGS_dryRun) {
|
2016-01-25 21:02:40 +00:00
|
|
|
SkDebugf("Running %s\t%s\n"
|
|
|
|
, bench->getUniqueName()
|
|
|
|
, config);
|
2016-02-08 21:49:12 +00:00
|
|
|
if (FLAGS_dryRun) {
|
|
|
|
continue;
|
|
|
|
}
|
2016-01-25 21:02:40 +00:00
|
|
|
}
|
|
|
|
|
2019-03-28 13:32:14 +00:00
|
|
|
if (FLAGS_purgeBetweenBenches) {
|
|
|
|
SkGraphics::PurgeAllCaches();
|
|
|
|
}
|
|
|
|
|
2017-09-08 20:05:23 +00:00
|
|
|
TRACE_EVENT2("skia", "Benchmark", "name", TRACE_STR_COPY(bench->getUniqueName()),
|
|
|
|
"config", TRACE_STR_COPY(config));
|
2017-08-31 18:09:22 +00:00
|
|
|
|
2015-06-26 15:12:46 +00:00
|
|
|
target->setup();
|
2014-11-21 14:19:36 +00:00
|
|
|
bench->perCanvasPreDraw(canvas);
|
|
|
|
|
2015-06-26 02:17:08 +00:00
|
|
|
int maxFrameLag;
|
2015-10-01 16:43:39 +00:00
|
|
|
int loops = target->needsFrameTiming(&maxFrameLag)
|
2015-06-26 15:12:46 +00:00
|
|
|
? setup_gpu_bench(target, bench.get(), maxFrameLag)
|
|
|
|
: setup_cpu_bench(overhead, target, bench.get());
|
2015-06-26 02:17:08 +00:00
|
|
|
|
2017-10-02 13:48:15 +00:00
|
|
|
if (kFailedLoops == loops) {
|
|
|
|
// Can't be timed. A warning note has already been printed.
|
|
|
|
cleanup_run(target);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
Run the first bench for 1000ms to warm up the nanobench if FLAGS_ms < 1000.
Otherwise, the first few benches' measurements will be inaccurate.
For example, without this CL, the first few measurements are:
337ns, 566µs, 1000µs, ... without "--ms 1000" arg
211ns, 285µs, 874µs, ... with "--ms 1000" arg
With this CL, the first few measurements are:
195ns, 296µs, 1.03ms, ... without "--ms 1000" arg
204ns, 280µs, 859µs, ... with "--ms 1000" arg
In the example above, the first two measurements are vastly (>50%)
different without this CL. I think that's the reason why I keep
using "--ms 1000" arg locally. But it's really only necessary for
the first bench to warm up nanobench. It's a waste to apply
"--ms 1000" to all the following benches.
Bug: skia:
Change-Id: I1924ba3ff9185ed89aeda72794fafd1fe6625eef
Reviewed-on: https://skia-review.googlesource.com/49742
Reviewed-by: Yuqian Li <liyuqian@google.com>
Commit-Queue: Yuqian Li <liyuqian@google.com>
2017-09-21 17:23:49 +00:00
|
|
|
if (runs == 0 && FLAGS_ms < 1000) {
|
|
|
|
// Run the first bench for 1000ms to warm up the nanobench if FLAGS_ms < 1000.
|
|
|
|
// Otherwise, the first few benches' measurements will be inaccurate.
|
|
|
|
auto stop = now_ms() + 1000;
|
|
|
|
do {
|
|
|
|
time(loops, bench.get(), target);
|
2020-02-28 16:05:44 +00:00
|
|
|
pool.drain();
|
Run the first bench for 1000ms to warm up the nanobench if FLAGS_ms < 1000.
Otherwise, the first few benches' measurements will be inaccurate.
For example, without this CL, the first few measurements are:
337ns, 566µs, 1000µs, ... without "--ms 1000" arg
211ns, 285µs, 874µs, ... with "--ms 1000" arg
With this CL, the first few measurements are:
195ns, 296µs, 1.03ms, ... without "--ms 1000" arg
204ns, 280µs, 859µs, ... with "--ms 1000" arg
In the example above, the first two measurements are vastly (>50%)
different without this CL. I think that's the reason why I keep
using "--ms 1000" arg locally. But it's really only necessary for
the first bench to warm up nanobench. It's a waste to apply
"--ms 1000" to all the following benches.
Bug: skia:
Change-Id: I1924ba3ff9185ed89aeda72794fafd1fe6625eef
Reviewed-on: https://skia-review.googlesource.com/49742
Reviewed-by: Yuqian Li <liyuqian@google.com>
Commit-Queue: Yuqian Li <liyuqian@google.com>
2017-09-21 17:23:49 +00:00
|
|
|
} while (now_ms() < stop);
|
|
|
|
}
|
|
|
|
|
2015-10-28 18:36:30 +00:00
|
|
|
if (FLAGS_ms) {
|
|
|
|
samples.reset();
|
|
|
|
auto stop = now_ms() + FLAGS_ms;
|
|
|
|
do {
|
2016-11-03 18:40:50 +00:00
|
|
|
samples.push_back(time(loops, bench.get(), target) / loops);
|
2020-02-28 16:05:44 +00:00
|
|
|
pool.drain();
|
2015-10-28 18:36:30 +00:00
|
|
|
} while (now_ms() < stop);
|
|
|
|
} else {
|
2015-06-26 02:17:08 +00:00
|
|
|
samples.reset(FLAGS_samples);
|
|
|
|
for (int s = 0; s < FLAGS_samples; s++) {
|
2016-11-03 18:40:50 +00:00
|
|
|
samples[s] = time(loops, bench.get(), target) / loops;
|
2020-02-28 16:05:44 +00:00
|
|
|
pool.drain();
|
2015-06-26 02:17:08 +00:00
|
|
|
}
|
|
|
|
}
|
2014-06-25 21:08:00 +00:00
|
|
|
|
2019-05-31 15:03:07 +00:00
|
|
|
// Scale each result to the benchmark's own units, time/unit.
|
|
|
|
for (double& sample : samples) {
|
|
|
|
sample *= (1.0 / bench->getUnits());
|
|
|
|
}
|
|
|
|
|
2015-12-02 17:05:37 +00:00
|
|
|
SkTArray<SkString> keys;
|
|
|
|
SkTArray<double> values;
|
2021-04-30 23:16:12 +00:00
|
|
|
if (configs[i].backend == Benchmark::kGPU_Backend) {
|
|
|
|
if (FLAGS_gpuStatsDump) {
|
|
|
|
// TODO cache stats
|
|
|
|
bench->getGpuStats(canvas, &keys, &values);
|
|
|
|
}
|
|
|
|
if (FLAGS_dmsaaStatsDump && bench->getDMSAAStats(canvas->recordingContext())) {
|
|
|
|
const auto& dmsaaStats = canvas->recordingContext()->priv().dmsaaStats();
|
|
|
|
dmsaaStats.dumpKeyValuePairs(&keys, &values);
|
|
|
|
dmsaaStats.dump();
|
|
|
|
combinedDMSAAStats.merge(dmsaaStats);
|
|
|
|
}
|
2015-12-02 17:05:37 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 14:19:36 +00:00
|
|
|
bench->perCanvasPostDraw(canvas);
|
|
|
|
|
2015-06-26 15:12:46 +00:00
|
|
|
if (Benchmark::kNonRendering_Backend != target->config.backend &&
|
2015-03-26 18:28:06 +00:00
|
|
|
!FLAGS_writePath.isEmpty() && FLAGS_writePath[0]) {
|
2014-08-07 21:28:50 +00:00
|
|
|
SkString pngFilename = SkOSPath::Join(FLAGS_writePath[0], config);
|
2014-09-10 19:05:59 +00:00
|
|
|
pngFilename = SkOSPath::Join(pngFilename.c_str(), bench->getUniqueName());
|
2014-08-07 21:28:50 +00:00
|
|
|
pngFilename.append(".png");
|
2015-06-26 15:12:46 +00:00
|
|
|
write_canvas_png(target, pngFilename);
|
2014-08-07 21:28:50 +00:00
|
|
|
}
|
|
|
|
|
2018-09-27 14:44:56 +00:00
|
|
|
// Building stats.plot often shows up in profiles,
|
|
|
|
// so skip building it when we're not going to print it anyway.
|
|
|
|
const bool want_plot = !FLAGS_quiet;
|
|
|
|
|
|
|
|
Stats stats(samples, want_plot);
|
2019-01-28 19:24:29 +00:00
|
|
|
log.beginObject(config);
|
|
|
|
|
|
|
|
log.beginObject("options");
|
|
|
|
log.appendString("name", bench->getName());
|
|
|
|
benchStream.fillCurrentOptions(log);
|
|
|
|
target->fillOptions(log);
|
|
|
|
log.endObject(); // options
|
|
|
|
|
|
|
|
// Metrics
|
|
|
|
log.appendMetric("min_ms", stats.min);
|
2021-06-01 13:39:11 +00:00
|
|
|
log.appendMetric("min_ratio", sk_ieee_double_divide(stats.median, stats.min));
|
2019-01-28 19:24:29 +00:00
|
|
|
log.beginArray("samples");
|
|
|
|
for (double sample : samples) {
|
|
|
|
log.appendDoubleDigits(sample, 16);
|
|
|
|
}
|
|
|
|
log.endArray(); // samples
|
|
|
|
benchStream.fillCurrentMetrics(log);
|
2021-04-30 23:16:12 +00:00
|
|
|
if (!keys.empty()) {
|
2015-12-02 17:05:37 +00:00
|
|
|
// dump to json, only SKPBench currently returns valid keys / values
|
|
|
|
SkASSERT(keys.count() == values.count());
|
|
|
|
for (int i = 0; i < keys.count(); i++) {
|
2019-01-28 19:24:29 +00:00
|
|
|
log.appendMetric(keys[i].c_str(), values[i]);
|
2015-12-02 17:05:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-28 19:24:29 +00:00
|
|
|
log.endObject(); // config
|
|
|
|
|
2014-10-14 15:40:43 +00:00
|
|
|
if (runs++ % FLAGS_flushEvery == 0) {
|
2019-01-28 19:24:29 +00:00
|
|
|
log.flush();
|
2014-10-14 15:40:43 +00:00
|
|
|
}
|
2014-07-14 18:30:37 +00:00
|
|
|
|
2014-08-07 21:28:50 +00:00
|
|
|
if (kAutoTuneLoops != FLAGS_loops) {
|
2015-06-26 15:12:46 +00:00
|
|
|
if (configs.count() == 1) {
|
2014-07-14 19:28:47 +00:00
|
|
|
config = ""; // Only print the config if we run the same bench on more than one.
|
|
|
|
}
|
2015-04-30 14:11:22 +00:00
|
|
|
SkDebugf("%4d/%-4dMB\t%s\t%s\n"
|
|
|
|
, sk_tools::getCurrResidentSetSizeMB()
|
|
|
|
, sk_tools::getMaxResidentSetSizeMB()
|
2014-09-18 14:39:42 +00:00
|
|
|
, bench->getUniqueName()
|
|
|
|
, config);
|
2014-06-25 21:08:00 +00:00
|
|
|
} else if (FLAGS_quiet) {
|
2015-12-04 14:35:30 +00:00
|
|
|
const char* mark = " ";
|
2019-01-14 21:34:50 +00:00
|
|
|
const double stddev_percent =
|
|
|
|
sk_ieee_double_divide(100 * sqrt(stats.var), stats.mean);
|
2015-12-04 14:35:30 +00:00
|
|
|
if (stddev_percent > 5) mark = "?";
|
|
|
|
if (stddev_percent > 10) mark = "!";
|
|
|
|
|
|
|
|
SkDebugf("%10.2f %s\t%s\t%s\n",
|
|
|
|
stats.median*1e3, mark, bench->getUniqueName(), config);
|
2017-07-05 02:56:06 +00:00
|
|
|
} else if (FLAGS_csv) {
|
2019-01-14 21:34:50 +00:00
|
|
|
const double stddev_percent =
|
|
|
|
sk_ieee_double_divide(100 * sqrt(stats.var), stats.mean);
|
2017-07-05 02:56:06 +00:00
|
|
|
SkDebugf("%g,%g,%g,%g,%g,%s,%s\n"
|
|
|
|
, stats.min
|
|
|
|
, stats.median
|
|
|
|
, stats.mean
|
|
|
|
, stats.max
|
|
|
|
, stddev_percent
|
|
|
|
, config
|
|
|
|
, bench->getUniqueName()
|
|
|
|
);
|
2014-06-25 21:08:00 +00:00
|
|
|
} else {
|
2017-07-05 02:56:06 +00:00
|
|
|
const char* format = "%4d/%-4dMB\t%d\t%s\t%s\t%s\t%s\t%.0f%%\t%s\t%s\t%s\n";
|
2019-01-14 21:34:50 +00:00
|
|
|
const double stddev_percent =
|
|
|
|
sk_ieee_double_divide(100 * sqrt(stats.var), stats.mean);
|
2017-07-05 02:56:06 +00:00
|
|
|
SkDebugf(format
|
2015-04-30 14:11:22 +00:00
|
|
|
, sk_tools::getCurrResidentSetSizeMB()
|
|
|
|
, sk_tools::getMaxResidentSetSizeMB()
|
2014-06-25 21:08:00 +00:00
|
|
|
, loops
|
2014-07-17 15:38:23 +00:00
|
|
|
, HUMANIZE(stats.min)
|
|
|
|
, HUMANIZE(stats.median)
|
|
|
|
, HUMANIZE(stats.mean)
|
|
|
|
, HUMANIZE(stats.max)
|
2014-06-25 21:08:00 +00:00
|
|
|
, stddev_percent
|
2015-10-28 18:36:30 +00:00
|
|
|
, FLAGS_ms ? to_string(samples.count()).c_str() : stats.plot.c_str()
|
2014-06-25 21:08:00 +00:00
|
|
|
, config
|
2014-09-10 19:05:59 +00:00
|
|
|
, bench->getUniqueName()
|
2014-06-25 21:08:00 +00:00
|
|
|
);
|
|
|
|
}
|
2015-12-02 17:05:37 +00:00
|
|
|
|
|
|
|
if (FLAGS_gpuStats && Benchmark::kGPU_Backend == configs[i].backend) {
|
2017-10-11 19:34:27 +00:00
|
|
|
target->dumpStats();
|
2014-10-24 17:40:50 +00:00
|
|
|
}
|
2015-12-02 17:05:37 +00:00
|
|
|
|
2015-06-26 20:32:53 +00:00
|
|
|
if (FLAGS_verbose) {
|
|
|
|
SkDebugf("Samples: ");
|
|
|
|
for (int i = 0; i < samples.count(); i++) {
|
|
|
|
SkDebugf("%s ", HUMANIZE(samples[i]));
|
|
|
|
}
|
|
|
|
SkDebugf("%s\n", bench->getUniqueName());
|
|
|
|
}
|
2015-06-26 15:12:46 +00:00
|
|
|
cleanup_run(target);
|
2019-05-31 14:49:12 +00:00
|
|
|
pool.drain();
|
2014-06-25 21:08:00 +00:00
|
|
|
}
|
2019-01-28 19:24:29 +00:00
|
|
|
if (!configs.empty()) {
|
|
|
|
log.endBench();
|
|
|
|
}
|
2014-06-25 21:08:00 +00:00
|
|
|
}
|
|
|
|
|
2021-04-30 23:16:12 +00:00
|
|
|
if (FLAGS_dmsaaStatsDump) {
|
|
|
|
SkDebugf("<<Total Combined DMSAA Stats>>\n");
|
|
|
|
combinedDMSAAStats.dump();
|
|
|
|
}
|
|
|
|
|
2017-01-26 21:48:28 +00:00
|
|
|
SkGraphics::PurgeAllCaches();
|
|
|
|
|
2019-01-28 19:24:29 +00:00
|
|
|
log.beginBench("memory_usage", 0, 0);
|
|
|
|
log.beginObject("meta"); // config
|
|
|
|
log.appendS32("max_rss_mb", sk_tools::getMaxResidentSetSizeMB());
|
|
|
|
log.endObject(); // config
|
|
|
|
log.endBench();
|
|
|
|
|
2020-07-08 18:12:43 +00:00
|
|
|
RunSkSLMemoryBenchmarks(&log);
|
|
|
|
|
2019-01-28 19:24:29 +00:00
|
|
|
log.endObject(); // results
|
|
|
|
log.endObject(); // root
|
|
|
|
log.flush();
|
2014-12-04 18:47:02 +00:00
|
|
|
|
2014-06-25 21:08:00 +00:00
|
|
|
return 0;
|
|
|
|
}
|