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>
|
|
|
|
|
2015-03-26 18:28:06 +00:00
|
|
|
#include "nanobench.h"
|
|
|
|
|
2016-02-11 14:45:51 +00:00
|
|
|
#include "AndroidCodecBench.h"
|
2014-06-25 21:08:00 +00:00
|
|
|
#include "Benchmark.h"
|
2015-09-22 18:56:16 +00:00
|
|
|
#include "BitmapRegionDecoderBench.h"
|
2015-04-01 19:09:17 +00:00
|
|
|
#include "CodecBench.h"
|
2015-09-22 18:56:16 +00:00
|
|
|
#include "CodecBenchPriv.h"
|
2014-06-25 21:08:00 +00:00
|
|
|
#include "CrashHandler.h"
|
2014-07-31 19:13:48 +00:00
|
|
|
#include "GMBench.h"
|
2014-08-19 22:55:55 +00:00
|
|
|
#include "ProcStats.h"
|
2014-07-14 18:30:37 +00:00
|
|
|
#include "ResultsWriter.h"
|
2014-09-10 19:19:30 +00:00
|
|
|
#include "RecordingBench.h"
|
2015-04-27 16:16:57 +00:00
|
|
|
#include "SKPAnimationBench.h"
|
2014-08-01 14:46:52 +00:00
|
|
|
#include "SKPBench.h"
|
2014-06-25 21:08:00 +00:00
|
|
|
#include "Stats.h"
|
|
|
|
|
2016-02-11 14:45:51 +00:00
|
|
|
#include "SkAndroidCodec.h"
|
2015-11-06 16:56:32 +00:00
|
|
|
#include "SkBitmapRegionDecoder.h"
|
2014-10-29 21:15:10 +00:00
|
|
|
#include "SkBBoxHierarchy.h"
|
2014-06-25 21:08:00 +00:00
|
|
|
#include "SkCanvas.h"
|
2015-04-01 19:09:17 +00:00
|
|
|
#include "SkCodec.h"
|
2014-07-22 17:15:34 +00:00
|
|
|
#include "SkCommonFlags.h"
|
Add config options to run different GPU APIs to dm and nanobench
Add extended config specification form that can be used to run different
gpu backend with different APIs.
The configs can be specified with the form:
gpu(api=string,dit=bool,nvpr=bool,samples=int)
This replaces and removes the --gpuAPI flag.
All existing configs should still work.
Adds following documentation:
out/Debug/dm --help config
Flags:
--config: type: string default: 565 8888 gpu nonrendering
Options: 565 8888 debug gpu gpudebug gpudft gpunull msaa16 msaa4
nonrendering null nullgpu nvprmsaa16 nvprmsaa4 pdf pdf_poppler skp svg
xps or use extended form 'backend(option=value,...)'.
Extended form: 'backend(option=value,...)'
Possible backends and options:
gpu(api=string,dit=bool,nvpr=bool,samples=int) GPU backend
api type: string default: native.
Select graphics API to use with gpu backend.
Options:
native Use platform default OpenGL or OpenGL ES backend.
gl Use OpenGL.
gles Use OpenGL ES.
debug Use debug OpenGL.
null Use null OpenGL.
dit type: bool default: false.
Use device independent text.
nvpr type: bool default: false.
Use NV_path_rendering OpenGL and OpenGL ES extension.
samples type: int default: 0.
Use multisampling with N samples.
Predefined configs:
gpu = gpu()
msaa4 = gpu(samples=4)
msaa16 = gpu(samples=16)
nvprmsaa4 = gpu(nvpr=true,samples=4)
nvprmsaa16 = gpu(nvpr=true,samples=16)
gpudft = gpu(dit=true)
gpudebug = gpu(api=debug)
gpunull = gpu(api=null)
debug = gpu(api=debug)
nullgpu = gpu(api=null)
BUG=skia:2992
Committed: https://skia.googlesource.com/skia/+/e13ca329fca4c28cf4e078561f591ab27b743d23
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1490113005
Committed: https://skia.googlesource.com/skia/+/c8b4336444e7b90382e04e33665fb3b8490b825b
Committed: https://skia.googlesource.com/skia/+/9ebc3f0ee6db215dde461dc4777d85988cf272dd
Review URL: https://codereview.chromium.org/1490113005
2015-12-23 09:33:00 +00:00
|
|
|
#include "SkCommonFlagsConfig.h"
|
2015-02-13 17:05:41 +00:00
|
|
|
#include "SkData.h"
|
2014-06-25 21:08:00 +00:00
|
|
|
#include "SkForceLinking.h"
|
|
|
|
#include "SkGraphics.h"
|
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
|
|
|
#include "SkOSFile.h"
|
|
|
|
#include "SkPictureRecorder.h"
|
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
|
|
|
#include "SkPictureUtils.h"
|
2014-06-25 21:08:00 +00:00
|
|
|
#include "SkString.h"
|
|
|
|
#include "SkSurface.h"
|
2014-11-21 14:19:36 +00:00
|
|
|
#include "SkTaskGroup.h"
|
2016-01-04 19:35:43 +00:00
|
|
|
#include "SkThreadUtils.h"
|
2016-02-09 15:18:08 +00:00
|
|
|
#include "ThermalManager.h"
|
2014-06-25 21:08:00 +00:00
|
|
|
|
2015-08-26 12:15:46 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2016-01-07 15:28:47 +00:00
|
|
|
#ifndef SK_BUILD_FOR_WIN32
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
2015-03-26 18:28:06 +00:00
|
|
|
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
|
|
|
|
#include "nanobenchAndroid.h"
|
|
|
|
#endif
|
|
|
|
|
2014-07-01 15:43:42 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2014-07-17 20:14:16 +00:00
|
|
|
#include "gl/GrGLDefines.h"
|
2015-05-29 15:02:10 +00:00
|
|
|
#include "GrCaps.h"
|
2014-07-01 15:43:42 +00:00
|
|
|
#include "GrContextFactory.h"
|
2014-08-13 17:46:31 +00:00
|
|
|
SkAutoTDelete<GrContextFactory> gGrFactory;
|
2014-07-01 15:43:42 +00:00
|
|
|
#endif
|
|
|
|
|
2015-05-22 21:01:46 +00:00
|
|
|
struct GrContextOptions;
|
|
|
|
|
2014-06-25 21:08:00 +00:00
|
|
|
__SK_FORCE_IMAGE_DECODER_LINKING;
|
|
|
|
|
2014-10-10 16:09:52 +00:00
|
|
|
static const int kAutoTuneLoops = 0;
|
2014-08-07 21:28:50 +00:00
|
|
|
|
2014-08-07 22:20:02 +00:00
|
|
|
static const int kDefaultLoops =
|
2014-08-07 21:28:50 +00:00
|
|
|
#ifdef SK_DEBUG
|
|
|
|
1;
|
2014-07-14 19:28:47 +00:00
|
|
|
#else
|
2014-08-07 21:28:50 +00:00
|
|
|
kAutoTuneLoops;
|
2014-07-14 19:28:47 +00:00
|
|
|
#endif
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2014-08-07 21:28:50 +00:00
|
|
|
DEFINE_int32(loops, kDefaultLoops, loops_help_txt().c_str());
|
|
|
|
|
2014-06-25 21:08:00 +00:00
|
|
|
DEFINE_int32(samples, 10, "Number of samples to measure for each bench.");
|
2015-10-28 18:36:30 +00:00
|
|
|
DEFINE_int32(ms, 0, "If >0, run each bench for this many ms instead of obeying --samples.");
|
2014-06-25 21:08:00 +00:00
|
|
|
DEFINE_int32(overheadLoops, 100000, "Loops to estimate timer overhead.");
|
|
|
|
DEFINE_double(overheadGoal, 0.0001,
|
|
|
|
"Loop until timer overhead is at most this fraction of our measurments.");
|
2014-07-01 15:43:42 +00:00
|
|
|
DEFINE_double(gpuMs, 5, "Target bench time in millseconds for GPU.");
|
2015-06-23 20:23:44 +00:00
|
|
|
DEFINE_int32(gpuFrameLag, 5, "If unknown, estimated maximum number of frames GPU allows to lag.");
|
2014-08-13 19:06:26 +00:00
|
|
|
DEFINE_bool(gpuCompressAlphaMasks, false, "Compress masks generated from falling back to "
|
|
|
|
"software path rendering.");
|
2014-06-25 21:08:00 +00:00
|
|
|
|
2014-07-14 18:30:37 +00:00
|
|
|
DEFINE_string(outResultsFile, "", "If given, write results here as JSON.");
|
2014-07-17 15:38:23 +00:00
|
|
|
DEFINE_int32(maxCalibrationAttempts, 3,
|
|
|
|
"Try up to this many times to guess loops for a bench, or skip the bench.");
|
|
|
|
DEFINE_int32(maxLoops, 1000000, "Never run a bench more times than this.");
|
2014-08-01 14:46:52 +00:00
|
|
|
DEFINE_string(clip, "0,0,1000,1000", "Clip for SKPs.");
|
|
|
|
DEFINE_string(scales, "1.0", "Space-separated scales for SKPs.");
|
2015-06-29 21:06:10 +00:00
|
|
|
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.");
|
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
|
|
|
DEFINE_bool(bbh, true, "Build a BBH for SKPs?");
|
2014-11-21 14:19:36 +00:00
|
|
|
DEFINE_bool(mpd, true, "Use MultiPictureDraw for the SKPs?");
|
2015-06-25 17:51:56 +00:00
|
|
|
DEFINE_bool(loopSKP, true, "Loop SKPs like we do for micro benches?");
|
2014-10-14 15:40:43 +00:00
|
|
|
DEFINE_int32(flushEvery, 10, "Flush --outResultsFile every Nth run.");
|
2015-01-21 23:50:13 +00:00
|
|
|
DEFINE_bool(resetGpuContext, true, "Reset the GrContext before running each test.");
|
2015-02-03 05:19:50 +00:00
|
|
|
DEFINE_bool(gpuStats, false, "Print GPU stats after each gpu benchmark?");
|
2015-12-02 17:05:37 +00:00
|
|
|
DEFINE_bool(gpuStatsDump, false, "Dump GPU states after each benchmark to json");
|
2016-01-04 19:35:43 +00:00
|
|
|
DEFINE_bool(keepAlive, false, "Print a message every so often so that we don't time out");
|
2016-02-09 15:18:08 +00:00
|
|
|
DEFINE_string(useThermalManager, "0,1,10,1000", "enabled,threshold,sleepTimeMs,TimeoutMs for "
|
|
|
|
"thermalManager\n");
|
2014-08-01 14:46:52 +00:00
|
|
|
|
2016-02-03 18:40:54 +00:00
|
|
|
DEFINE_string(sourceType, "",
|
|
|
|
"Apply usual --match rules to source type: bench, gm, skp, image, etc.");
|
|
|
|
DEFINE_string(benchType, "",
|
|
|
|
"Apply usual --match rules to bench type: micro, recording, playback, skcodec, etc.");
|
|
|
|
|
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) {
|
2014-09-24 13:34:09 +00:00
|
|
|
if (FLAGS_verbose) return SkStringPrintf("%llu", (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) {
|
|
|
|
this->surface.reset(SkSurface::NewRaster(info));
|
|
|
|
if (!this->surface.get()) {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
bmp->setInfo(canvas->imageInfo());
|
|
|
|
if (!canvas->readPixels(bmp, 0, 0)) {
|
|
|
|
SkDebugf("Can't read canvas pixels.\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
struct GPUTarget : public Target {
|
2015-08-27 14:41:13 +00:00
|
|
|
explicit GPUTarget(const Config& c) : Target(c), gl(nullptr) { }
|
2015-03-26 18:28:06 +00:00
|
|
|
SkGLContext* gl;
|
|
|
|
|
|
|
|
void setup() override {
|
|
|
|
this->gl->makeCurrent();
|
|
|
|
// Make sure we're done with whatever came before.
|
|
|
|
SK_GL(*this->gl, Finish());
|
|
|
|
}
|
|
|
|
void endTiming() override {
|
|
|
|
if (this->gl) {
|
|
|
|
SK_GL(*this->gl, Flush());
|
2016-01-20 21:09:12 +00:00
|
|
|
this->gl->waitOnSyncOrSwap();
|
2015-03-26 18:28:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
void fence() override {
|
|
|
|
SK_GL(*this->gl, Finish());
|
|
|
|
}
|
2015-04-30 14:11:22 +00:00
|
|
|
|
2015-06-23 20:23:44 +00:00
|
|
|
bool needsFrameTiming(int* maxFrameLag) const override {
|
|
|
|
if (!this->gl->getMaxGpuFrameLag(maxFrameLag)) {
|
|
|
|
// Frame lag is unknown.
|
|
|
|
*maxFrameLag = FLAGS_gpuFrameLag;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2015-03-26 18:28:06 +00:00
|
|
|
bool init(SkImageInfo info, Benchmark* bench) override {
|
2015-08-31 19:39:41 +00:00
|
|
|
uint32_t flags = this->config.useDFText ? SkSurfaceProps::kUseDeviceIndependentFonts_Flag :
|
|
|
|
0;
|
2015-03-26 18:28:06 +00:00
|
|
|
SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType);
|
2015-12-10 14:28:13 +00:00
|
|
|
this->surface.reset(SkSurface::NewRenderTarget(gGrFactory->get(this->config.ctxType,
|
|
|
|
this->config.ctxOptions),
|
2015-03-26 18:28:06 +00:00
|
|
|
SkSurface::kNo_Budgeted, info,
|
|
|
|
this->config.samples, &props));
|
Add config options to run different GPU APIs to dm and nanobench
Add extended config specification form that can be used to run different
gpu backend with different APIs.
The configs can be specified with the form:
gpu(api=string,dit=bool,nvpr=bool,samples=int)
This replaces and removes the --gpuAPI flag.
All existing configs should still work.
Adds following documentation:
out/Debug/dm --help config
Flags:
--config: type: string default: 565 8888 gpu nonrendering
Options: 565 8888 debug gpu gpudebug gpudft gpunull msaa16 msaa4
nonrendering null nullgpu nvprmsaa16 nvprmsaa4 pdf pdf_poppler skp svg
xps or use extended form 'backend(option=value,...)'.
Extended form: 'backend(option=value,...)'
Possible backends and options:
gpu(api=string,dit=bool,nvpr=bool,samples=int) GPU backend
api type: string default: native.
Select graphics API to use with gpu backend.
Options:
native Use platform default OpenGL or OpenGL ES backend.
gl Use OpenGL.
gles Use OpenGL ES.
debug Use debug OpenGL.
null Use null OpenGL.
dit type: bool default: false.
Use device independent text.
nvpr type: bool default: false.
Use NV_path_rendering OpenGL and OpenGL ES extension.
samples type: int default: 0.
Use multisampling with N samples.
Predefined configs:
gpu = gpu()
msaa4 = gpu(samples=4)
msaa16 = gpu(samples=16)
nvprmsaa4 = gpu(nvpr=true,samples=4)
nvprmsaa16 = gpu(nvpr=true,samples=16)
gpudft = gpu(dit=true)
gpudebug = gpu(api=debug)
gpunull = gpu(api=null)
debug = gpu(api=debug)
nullgpu = gpu(api=null)
BUG=skia:2992
Committed: https://skia.googlesource.com/skia/+/e13ca329fca4c28cf4e078561f591ab27b743d23
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1490113005
Committed: https://skia.googlesource.com/skia/+/c8b4336444e7b90382e04e33665fb3b8490b825b
Committed: https://skia.googlesource.com/skia/+/9ebc3f0ee6db215dde461dc4777d85988cf272dd
Review URL: https://codereview.chromium.org/1490113005
2015-12-23 09:33:00 +00:00
|
|
|
this->gl = gGrFactory->getContextInfo(this->config.ctxType,
|
2016-01-07 07:49:30 +00:00
|
|
|
this->config.ctxOptions).fGLContext;
|
2015-03-26 18:28:06 +00:00
|
|
|
if (!this->surface.get()) {
|
|
|
|
return false;
|
|
|
|
}
|
2015-06-23 20:23:44 +00:00
|
|
|
if (!this->gl->fenceSyncSupport()) {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
void fillOptions(ResultsWriter* log) override {
|
|
|
|
const GrGLubyte* version;
|
|
|
|
SK_GL_RET(*this->gl, version, GetString(GR_GL_VERSION));
|
|
|
|
log->configOption("GL_VERSION", (const char*)(version));
|
|
|
|
|
|
|
|
SK_GL_RET(*this->gl, version, GetString(GR_GL_RENDERER));
|
|
|
|
log->configOption("GL_RENDERER", (const char*) version);
|
|
|
|
|
|
|
|
SK_GL_RET(*this->gl, version, GetString(GR_GL_VENDOR));
|
|
|
|
log->configOption("GL_VENDOR", (const char*) version);
|
|
|
|
|
|
|
|
SK_GL_RET(*this->gl, version, GetString(GR_GL_SHADING_LANGUAGE_VERSION));
|
|
|
|
log->configOption("GL_SHADING_LANGUAGE_VERSION", (const char*) version);
|
|
|
|
}
|
|
|
|
};
|
2015-04-30 14:11:22 +00:00
|
|
|
|
2015-03-26 18:28:06 +00:00
|
|
|
#endif
|
|
|
|
|
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);
|
2014-06-25 21:08:00 +00:00
|
|
|
if (canvas) {
|
|
|
|
canvas->flush();
|
|
|
|
}
|
2015-03-27 19:11:44 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
if (!SkImageEncoder::EncodeStream(&stream, bmp, SkImageEncoder::kPNG_Type, 100)) {
|
|
|
|
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
|
|
|
//
|
2014-07-01 15:43:42 +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.
|
2015-06-23 20:23:44 +00:00
|
|
|
for (int i = 0; i < maxGpuFrameLag - 1; 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
|
|
|
|
2014-07-22 20:09:05 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
#define kBogusGLContextType GrContextFactory::kNative_GLContextType
|
2015-12-10 14:28:13 +00:00
|
|
|
#define kBogusGLContextOptions GrContextFactory::kNone_GLContextOptions
|
2014-07-22 20:09:05 +00:00
|
|
|
#else
|
|
|
|
#define kBogusGLContextType 0
|
2015-12-10 14:28:13 +00:00
|
|
|
#define kBogusGLContextOptions 0
|
2014-07-31 19:13:48 +00:00
|
|
|
#endif
|
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 SK_SUPPORT_GPU
|
|
|
|
if (const auto* gpuConfig = config->asConfigGpu()) {
|
|
|
|
if (!FLAGS_gpu)
|
|
|
|
return;
|
|
|
|
|
|
|
|
const auto ctxOptions = gpuConfig->getUseNVPR() ? GrContextFactory::kEnableNVPR_GLContextOptions
|
|
|
|
: GrContextFactory::kNone_GLContextOptions;
|
|
|
|
const auto ctxType = gpuConfig->getContextType();
|
|
|
|
const auto sampleCount = gpuConfig->getSamples();
|
|
|
|
|
|
|
|
if (const GrContext* ctx = gGrFactory->get(ctxType, ctxOptions)) {
|
|
|
|
const auto maxSampleCount = ctx->caps()->maxSampleCount();
|
|
|
|
if (sampleCount > ctx->caps()->maxSampleCount()) {
|
|
|
|
SkDebugf("Configuration sample count %d exceeds maximum %d.\n",
|
|
|
|
sampleCount, maxSampleCount);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
SkDebugf("No context was available matching config type and options.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Config target = {
|
|
|
|
config->getTag(),
|
|
|
|
Benchmark::kGPU_Backend,
|
|
|
|
kN32_SkColorType,
|
|
|
|
kPremul_SkAlphaType,
|
|
|
|
sampleCount,
|
|
|
|
ctxType,
|
|
|
|
ctxOptions,
|
|
|
|
false };
|
|
|
|
|
|
|
|
configs->push_back(target);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define CPU_CONFIG(name, backend, color, alpha) \
|
|
|
|
if (config->getTag().equals(#name)) { \
|
|
|
|
Config config = { SkString(#name), Benchmark::backend, color, alpha, 0, \
|
|
|
|
kBogusGLContextType, kBogusGLContextOptions, \
|
|
|
|
false }; \
|
|
|
|
configs->push_back(config); \
|
|
|
|
return; \
|
2014-06-25 21:08:00 +00:00
|
|
|
}
|
2014-07-31 19:13:48 +00:00
|
|
|
|
2014-07-09 15:46:49 +00:00
|
|
|
if (FLAGS_cpu) {
|
2014-07-22 20:09:05 +00:00
|
|
|
CPU_CONFIG(nonrendering, kNonRendering_Backend, kUnknown_SkColorType, kUnpremul_SkAlphaType)
|
|
|
|
CPU_CONFIG(8888, kRaster_Backend, kN32_SkColorType, kPremul_SkAlphaType)
|
|
|
|
CPU_CONFIG(565, kRaster_Backend, kRGB_565_SkColorType, kOpaque_SkAlphaType)
|
2014-07-09 15:46:49 +00:00
|
|
|
}
|
2014-06-25 21:08:00 +00:00
|
|
|
|
2016-01-28 14:05:43 +00:00
|
|
|
#undef CPU_CONFIG
|
2015-03-26 18:28:06 +00:00
|
|
|
|
|
|
|
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
|
2016-01-28 21:57:02 +00:00
|
|
|
if (config->getTag().equals("hwui")) {
|
|
|
|
Config config = { SkString("hwui"), Benchmark::kHWUI_Backend, kRGBA_8888_SkColorType,
|
2015-12-10 14:28:13 +00:00
|
|
|
kPremul_SkAlphaType, 0, kBogusGLContextType, kBogusGLContextOptions,
|
|
|
|
false };
|
2016-01-28 14:05:43 +00:00
|
|
|
configs->push_back(config);
|
2015-03-26 18:28:06 +00:00
|
|
|
}
|
|
|
|
#endif
|
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) {
|
|
|
|
create_config(array[i], configs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
config.color, config.alpha);
|
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) {
|
2014-07-22 20:09:05 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2015-03-26 18:28:06 +00:00
|
|
|
case Benchmark::kGPU_Backend:
|
|
|
|
target = new GPUTarget(config);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
|
|
|
|
case Benchmark::kHWUI_Backend:
|
|
|
|
target = new HWUITarget(config, bench);
|
|
|
|
break;
|
2014-07-22 20:09:05 +00:00
|
|
|
#endif
|
2015-03-26 18:28:06 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2015-11-06 16:56:32 +00:00
|
|
|
static bool valid_brd_bench(SkData* encoded, SkBitmapRegionDecoder::Strategy strategy,
|
2015-09-22 18:56:16 +00:00
|
|
|
SkColorType colorType, uint32_t sampleSize, uint32_t minOutputSize, int* width,
|
|
|
|
int* height) {
|
2015-11-06 16:56:32 +00:00
|
|
|
SkAutoTDelete<SkBitmapRegionDecoder> brd(
|
|
|
|
SkBitmapRegionDecoder::Create(encoded, strategy));
|
2015-09-22 18:56:16 +00:00
|
|
|
if (nullptr == brd.get()) {
|
|
|
|
// This is indicates that subset decoding is not supported for a particular image format.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-10-27 19:50:25 +00:00
|
|
|
SkBitmap bitmap;
|
|
|
|
if (!brd->decodeRegion(&bitmap, nullptr, SkIRect::MakeXYWH(0, 0, brd->width(), brd->height()),
|
|
|
|
1, colorType, false)) {
|
|
|
|
return false;
|
|
|
|
}
|
2015-09-22 18:56:16 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
if (FLAGS_abandonGpuContext) {
|
|
|
|
gGrFactory->abandonContexts();
|
|
|
|
}
|
|
|
|
if (FLAGS_resetGpuContext || FLAGS_abandonGpuContext) {
|
|
|
|
gGrFactory->destroyContexts();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-07-31 19:13:48 +00:00
|
|
|
class BenchmarkStream {
|
|
|
|
public:
|
2014-08-01 14:46:52 +00:00
|
|
|
BenchmarkStream() : fBenches(BenchRegistry::Head())
|
|
|
|
, fGMs(skiagm::GMRegistry::Head())
|
2014-09-10 19:19:30 +00:00
|
|
|
, fCurrentRecording(0)
|
2014-08-01 14:46:52 +00:00
|
|
|
, fCurrentScale(0)
|
2014-11-21 14:19:36 +00:00
|
|
|
, fCurrentSKP(0)
|
2015-02-13 17:05:41 +00:00
|
|
|
, fCurrentUseMPD(0)
|
2015-04-01 19:09:17 +00:00
|
|
|
, fCurrentCodec(0)
|
2016-02-11 14:45:51 +00:00
|
|
|
, fCurrentAndroidCodec(0)
|
2015-09-22 18:56:16 +00:00
|
|
|
, fCurrentBRDImage(0)
|
2015-02-13 17:05:41 +00:00
|
|
|
, fCurrentColorType(0)
|
2016-01-07 22:20:20 +00:00
|
|
|
, fCurrentAlphaType(0)
|
2015-06-09 20:56:10 +00:00
|
|
|
, fCurrentSubsetType(0)
|
2015-09-22 18:56:16 +00:00
|
|
|
, fCurrentBRDStrategy(0)
|
2016-02-11 14:45:51 +00:00
|
|
|
, fCurrentSampleSize(0)
|
2015-06-09 20:56:10 +00:00
|
|
|
, fCurrentAnimSKP(0) {
|
2014-08-01 14:46:52 +00:00
|
|
|
for (int i = 0; i < FLAGS_skps.count(); i++) {
|
|
|
|
if (SkStrEndsWith(FLAGS_skps[i], ".skp")) {
|
|
|
|
fSKPs.push_back() = FLAGS_skps[i];
|
|
|
|
} else {
|
|
|
|
SkOSFile::Iter it(FLAGS_skps[i], ".skp");
|
|
|
|
SkString path;
|
|
|
|
while (it.next(&path)) {
|
|
|
|
fSKPs.push_back() = SkOSPath::Join(FLAGS_skps[0], path.c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2014-11-21 14:19:36 +00:00
|
|
|
if (FLAGS_mpd) {
|
|
|
|
fUseMPDs.push_back() = true;
|
|
|
|
}
|
2015-06-15 15:56:38 +00:00
|
|
|
fUseMPDs.push_back() = false;
|
2015-03-12 15:24:21 +00:00
|
|
|
|
2015-02-13 17:05:41 +00:00
|
|
|
// Prepare the images for decoding
|
2016-02-03 20:19:11 +00:00
|
|
|
if (!CollectImages(&fImages)) {
|
|
|
|
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
|
|
|
|
const SkColorType colorTypes[] =
|
2015-06-09 20:56:10 +00:00
|
|
|
{ kN32_SkColorType,
|
|
|
|
kRGB_565_SkColorType,
|
|
|
|
kAlpha_8_SkColorType,
|
|
|
|
kIndex_8_SkColorType,
|
|
|
|
kGray_8_SkColorType };
|
2015-10-20 23:45:56 +00:00
|
|
|
fColorTypes.reset(colorTypes, SK_ARRAY_COUNT(colorTypes));
|
2014-08-01 14:46:52 +00:00
|
|
|
}
|
2014-07-31 19:13:48 +00:00
|
|
|
|
2014-09-10 19:19:30 +00:00
|
|
|
static bool ReadPicture(const char* path, SkAutoTUnref<SkPicture>* pic) {
|
|
|
|
// 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.
|
2016-02-17 19:10:16 +00:00
|
|
|
if (SkCommandLineFlags::ShouldSkip(FLAGS_match, SkOSPath::Basename(path).c_str())) {
|
2014-09-10 19:19:30 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-01-21 20:09:53 +00:00
|
|
|
SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(path));
|
2015-08-27 14:41:13 +00:00
|
|
|
if (stream.get() == nullptr) {
|
2014-09-10 19:19:30 +00:00
|
|
|
SkDebugf("Could not read %s.\n", path);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
Revert of nanobench: lazily decode bitmaps in .skps. (patchset #1 id:1 of https://codereview.chromium.org/743613005/)
Reason for revert:
Well, it still crashes.
Original issue's description:
> nanobench: lazily decode bitmaps in .skps.
>
> This cuts down on tool overhead when running something like recording only,
> $ out/Release/nanobench --match skp --config nonrendering
> which doesn't usually ever need to decode the images.
>
> The actual measurements for recording don't change, as the decode is not in the timed section. It just skips irrelevant code, removing it from the profile and making the tool run faster.
>
> This does, however, make a significant difference for playback speed. Most skps draw faster with this patch, some slower. I don't really have a good intuition for what's going on here. There is a fixed clip acting as a viewport, so there are probably lots of images that don't ever need to be decoded. Ideas? Is this perhaps because we're now blitting from smaller, partially decoded source images?
>
> ~/skia (clean) $ compare clean.log lazy-decode-bitmaps.log
> tabl_slashdot.skp_1 2.76ms -> 4.33ms 1.57x
> tabl_slashdot.skp_1_mpd 2.79ms -> 4.07ms 1.46x
> tabl_sahadan.skp_1 3.41ms -> 4.87ms 1.43x
> tabl_googleblog.skp_1 1.52ms -> 2.05ms 1.35x
> tabl_techmeme.skp_1_mpd 1.14ms -> 1.51ms 1.32x
> tabl_transformice.skp_1 2.61ms -> 3.43ms 1.31x
> tabl_sahadan.skp_1_mpd 3.54ms -> 4.48ms 1.26x
> tabl_techmeme.skp_1 1.01ms -> 1.27ms 1.26x
> tabl_nytimes.skp_1_mpd 1ms -> 1.23ms 1.23x
> tabl_worldjournal.skp_1_mpd 1.98ms -> 2.43ms 1.23x
> tabl_pravda.skp_1_mpd 2.05ms -> 2.51ms 1.22x
> tabl_transformice.skp_1_mpd 2.75ms -> 3.19ms 1.16x
> tabl_nytimes.skp_1 874us -> 1.01ms 1.15x
> tabl_pravda.skp_1 1.83ms -> 1.99ms 1.09x
> tabl_worldjournal.skp_1 1.76ms -> 1.91ms 1.09x
> desk_wowwiki.skp_1_mpd 3.7ms -> 3.9ms 1.05x
> tabl_digg.skp_1 3.99ms -> 4.16ms 1.04x
> tabl_ukwsj.skp_1_mpd 3ms -> 3.12ms 1.04x
> desk_booking.skp_1 3.74ms -> 3.81ms 1.02x
> desk_googlespreadsheetdashed.skp_1 10.6ms -> 10.6ms 1x
> tabl_ukwsj.skp_1 2.88ms -> 2.89ms 1x
> desk_googlespreadsheetdashed.skp_1_mpd 11.8ms -> 11.8ms 1x
> desk_jsfiddlehumperclip.skp_1_mpd 891us -> 888us 1x
> desk_googlespreadsheet.skp_1 4.65ms -> 4.62ms 0.99x
> tabl_gspro.skp_1_mpd 1.97ms -> 1.94ms 0.99x
> desk_booking.skp_1_mpd 4.1ms -> 4ms 0.98x
> desk_carsvg.skp_1 18.2ms -> 17.7ms 0.97x
> desk_gmailthread.skp_1_mpd 2.81ms -> 2.73ms 0.97x
> desk_tigersvg.skp_1_mpd 19.5ms -> 18.9ms 0.97x
> desk_mapsvg.skp_1 88.4ms -> 85.6ms 0.97x
> tabl_cnet.skp_1_mpd 1.43ms -> 1.38ms 0.97x
> desk_jsfiddlebigcar.skp_1 1.26ms -> 1.22ms 0.96x
> desk_gws.skp_1 1.87ms -> 1.8ms 0.96x
> desk_linkedin.skp_1 2.07ms -> 1.98ms 0.96x
> tabl_deviantart.skp_1_mpd 118ms -> 113ms 0.96x
> tabl_cnet.skp_1 1.2ms -> 1.14ms 0.95x
> tabl_androidpolice.skp_1_mpd 5.95ms -> 5.63ms 0.95x
> desk_sfgate.skp_1 1.75ms -> 1.64ms 0.94x
> desk_twitter.skp_1 74ms -> 69.6ms 0.94x
> desk_youtube.skp_1_mpd 3.17ms -> 2.96ms 0.93x
> desk_gmailthread.skp_1 2.73ms -> 2.54ms 0.93x
> desk_silkfinance.skp_1_mpd 1.71ms -> 1.59ms 0.93x
> desk_jsfiddlebigcar.skp_1_mpd 1.45ms -> 1.35ms 0.93x
> desk_pokemonwiki.skp_1_mpd 2.72ms -> 2.51ms 0.92x
> desk_gws.skp_1_mpd 2.14ms -> 1.98ms 0.92x
> desk_googlehome.skp_1 563us -> 517us 0.92x
> desk_espn.skp_1 4.24ms -> 3.89ms 0.92x
> tabl_culturalsolutions.skp_1 12.7ms -> 11.6ms 0.91x
> desk_sfgate.skp_1_mpd 1.91ms -> 1.74ms 0.91x
> tabl_hsfi.skp_1 1.06ms -> 966us 0.91x
> desk_samoasvg.skp_1_mpd 10.5ms -> 9.47ms 0.91x
> desk_facebook.skp_1_mpd 3.8ms -> 3.43ms 0.9x
> desk_youtube.skp_1 3.52ms -> 3.14ms 0.89x
> desk_ebay.skp_1_mpd 2.95ms -> 2.62ms 0.89x
> desk_samoasvg.skp_1 10.9ms -> 9.66ms 0.89x
> desk_googlespreadsheet.skp_1_mpd 5.59ms -> 4.94ms 0.88x
> desk_mapsvg.skp_1_mpd 100ms -> 87.9ms 0.88x
> desk_espn.skp_1_mpd 4.7ms -> 4.12ms 0.88x
> desk_wordpress.skp_1_mpd 1.92ms -> 1.68ms 0.87x
> tabl_deviantart.skp_1 140ms -> 122ms 0.87x
> tabl_cuteoverload.skp_1_mpd 4.41ms -> 3.83ms 0.87x
> desk_tigersvg.skp_1 19.6ms -> 17ms 0.87x
> tabl_googlecalendar.skp_1 4.01ms -> 3.44ms 0.86x
> desk_blogger.skp_1 2.49ms -> 2.14ms 0.86x
> desk_chalkboard.skp_1_mpd 52.7ms -> 45ms 0.85x
> desk_weather.skp_1 2.88ms -> 2.46ms 0.85x
> desk_chalkboard.skp_1 51ms -> 43.4ms 0.85x
> desk_yahooanswers.skp_1 2.74ms -> 2.32ms 0.85x
> desk_forecastio.skp_1_mpd 1.26ms -> 1.07ms 0.85x
> tabl_androidpolice.skp_1 5.18ms -> 4.34ms 0.84x
> desk_yahooanswers.skp_1_mpd 3.44ms -> 2.85ms 0.83x
> tabl_cnn.skp_1_mpd 2.59ms -> 2.15ms 0.83x
> desk_pinterest.skp_1 2.69ms -> 2.22ms 0.83x
> tabl_hsfi.skp_1_mpd 1.6ms -> 1.32ms 0.82x
> tabl_culturalsolutions.skp_1_mpd 13.8ms -> 11.3ms 0.82x
> desk_twitter.skp_1_mpd 76.6ms -> 63ms 0.82x
> desk_ebay.skp_1 3.11ms -> 2.51ms 0.81x
> tabl_mlb.skp_1_mpd 3.17ms -> 2.53ms 0.8x
> tabl_mozilla.skp_1 2.42ms -> 1.91ms 0.79x
> desk_pokemonwiki.skp_1 2.84ms -> 2.22ms 0.78x
> desk_carsvg.skp_1_mpd 23.3ms -> 17.8ms 0.77x
> desk_wowwiki.skp_1 4.21ms -> 3.21ms 0.76x
> desk_amazon.skp_1 963us -> 728us 0.76x
> desk_css3gradients.skp_1 2.58ms -> 1.92ms 0.74x
> tabl_cuteoverload.skp_1 4.55ms -> 3.38ms 0.74x
> tabl_cnn.skp_1 3.13ms -> 2.29ms 0.73x
> tabl_googleblog.skp_1_mpd 2.32ms -> 1.7ms 0.73x
> desk_mobilenews.skp_1 3.65ms -> 2.61ms 0.71x
> desk_googleplus.skp_1 3.76ms -> 2.66ms 0.71x
> tabl_mozilla.skp_1_mpd 2.88ms -> 2.03ms 0.71x
> desk_pinterest.skp_1_mpd 3.17ms -> 2.21ms 0.7x
> desk_css3gradients.skp_1_mpd 2.98ms -> 2.07ms 0.69x
> desk_silkfinance.skp_1 2.06ms -> 1.42ms 0.69x
> desk_facebook.skp_1 4.5ms -> 3.07ms 0.68x
> desk_mobilenews.skp_1_mpd 4.05ms -> 2.73ms 0.68x
> desk_baidu.skp_1_mpd 2.73ms -> 1.81ms 0.66x
> desk_weather.skp_1_mpd 3.93ms -> 2.5ms 0.64x
> desk_wordpress.skp_1 2.15ms -> 1.36ms 0.63x
> desk_googlehome.skp_1_mpd 1.02ms -> 605us 0.59x
> desk_fontwipe.skp_1 722us -> 402us 0.56x
> desk_fontwipe.skp_1_mpd 897us -> 486us 0.54x
> desk_baidu.skp_1 3.02ms -> 1.6ms 0.53x
> desk_forecastio.skp_1 2.01ms -> 999us 0.5x
> desk_amazon.skp_1_mpd 1.77ms -> 860us 0.49x
>
> BUG=skia:
>
> Committed: https://skia.googlesource.com/skia/+/7e225bdb1f00ae4aed524ff8d0a61df3d3abb109
>
> Committed: https://skia.googlesource.com/skia/+/1b6b626f9bc0deebe4fe2e63f422d6b122419205
TBR=reed@google.com,robertphillips@google.com,scroggo@google.com,mtklein@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:
Review URL: https://codereview.chromium.org/902783005
2015-02-09 19:58:41 +00:00
|
|
|
pic->reset(SkPicture::CreateFromStream(stream.get()));
|
2015-08-27 14:41:13 +00:00
|
|
|
if (pic->get() == nullptr) {
|
2014-09-10 19:19:30 +00:00
|
|
|
SkDebugf("Could not read %s as an SkPicture.\n", path);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-08-01 14:46:52 +00:00
|
|
|
Benchmark* next() {
|
2016-02-03 18:40:54 +00:00
|
|
|
SkAutoTDelete<Benchmark> bench;
|
|
|
|
do {
|
|
|
|
bench.reset(this->rawNext());
|
|
|
|
if (!bench) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
} while(SkCommandLineFlags::ShouldSkip(FLAGS_sourceType, fSourceType) ||
|
|
|
|
SkCommandLineFlags::ShouldSkip(FLAGS_benchType, fBenchType));
|
|
|
|
return bench.detach();
|
|
|
|
}
|
|
|
|
|
|
|
|
Benchmark* rawNext() {
|
2014-07-31 19:13:48 +00:00
|
|
|
if (fBenches) {
|
2015-08-27 14:41:13 +00:00
|
|
|
Benchmark* bench = fBenches->factory()(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) {
|
2015-08-27 14:41:13 +00:00
|
|
|
SkAutoTDelete<skiagm::GM> gm(fGMs->factory()(nullptr));
|
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";
|
2015-08-26 20:07:48 +00:00
|
|
|
return new GMBench(gm.detach());
|
2014-07-31 19:13:48 +00:00
|
|
|
}
|
|
|
|
}
|
2014-08-01 14:46:52 +00:00
|
|
|
|
2014-09-10 19:19:30 +00:00
|
|
|
// First add all .skps as RecordingBenches.
|
|
|
|
while (fCurrentRecording < fSKPs.count()) {
|
|
|
|
const SkString& path = fSKPs[fCurrentRecording++];
|
|
|
|
SkAutoTUnref<SkPicture> pic;
|
|
|
|
if (!ReadPicture(path.c_str(), &pic)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
SkString name = SkOSPath::Basename(path.c_str());
|
|
|
|
fSourceType = "skp";
|
|
|
|
fBenchType = "recording";
|
2014-12-15 17:13:35 +00:00
|
|
|
fSKPBytes = static_cast<double>(SkPictureUtils::ApproximateBytesUsed(pic));
|
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
|
|
|
fSKPOps = pic->approximateOpCount();
|
2015-08-26 20:07:48 +00:00
|
|
|
return new RecordingBench(name.c_str(), pic.get(), FLAGS_bbh);
|
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()) {
|
2014-11-21 14:19:36 +00:00
|
|
|
const SkString& path = fSKPs[fCurrentSKP];
|
2014-09-10 19:19:30 +00:00
|
|
|
SkAutoTUnref<SkPicture> pic;
|
|
|
|
if (!ReadPicture(path.c_str(), &pic)) {
|
2014-11-21 14:19:36 +00:00
|
|
|
fCurrentSKP++;
|
2014-08-01 14:46:52 +00:00
|
|
|
continue;
|
|
|
|
}
|
2014-11-21 14:19:36 +00:00
|
|
|
|
|
|
|
while (fCurrentUseMPD < fUseMPDs.count()) {
|
|
|
|
if (FLAGS_bbh) {
|
|
|
|
// The SKP we read off disk doesn't have a BBH. Re-record so it grows one.
|
|
|
|
SkRTreeFactory factory;
|
|
|
|
SkPictureRecorder recorder;
|
|
|
|
static const int kFlags = SkPictureRecorder::kComputeSaveLayerInfo_RecordFlag;
|
|
|
|
pic->playback(recorder.beginRecording(pic->cullRect().width(),
|
|
|
|
pic->cullRect().height(),
|
2015-01-15 18:56:12 +00:00
|
|
|
&factory,
|
2014-12-09 18:28:00 +00:00
|
|
|
fUseMPDs[fCurrentUseMPD] ? kFlags : 0));
|
2014-11-21 14:19:36 +00:00
|
|
|
pic.reset(recorder.endRecording());
|
|
|
|
}
|
|
|
|
SkString name = SkOSPath::Basename(path.c_str());
|
|
|
|
fSourceType = "skp";
|
|
|
|
fBenchType = "playback";
|
2015-08-26 20:07:48 +00:00
|
|
|
return new SKPBench(name.c_str(), pic.get(), fClip, fScales[fCurrentScale],
|
|
|
|
fUseMPDs[fCurrentUseMPD++], FLAGS_loopSKP);
|
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
|
|
|
}
|
2014-11-21 14:19:36 +00:00
|
|
|
fCurrentUseMPD = 0;
|
|
|
|
fCurrentSKP++;
|
2014-08-01 14:46:52 +00:00
|
|
|
}
|
|
|
|
fCurrentSKP = 0;
|
|
|
|
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];
|
|
|
|
SkAutoTUnref<SkPicture> pic;
|
|
|
|
if (!ReadPicture(path.c_str(), &pic)) {
|
|
|
|
fCurrentAnimSKP++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
fCurrentAnimSKP++;
|
|
|
|
SkString name = SkOSPath::Basename(path.c_str());
|
2015-06-29 21:06:10 +00:00
|
|
|
SkAutoTUnref<SKPAnimationBench::Animation> animation(
|
|
|
|
SKPAnimationBench::CreateZoomAnimation(fZoomMax, fZoomPeriodMs));
|
2015-08-26 20:07:48 +00:00
|
|
|
return new SKPAnimationBench(name.c_str(), pic.get(), fClip, animation,
|
|
|
|
FLAGS_loopSKP);
|
2015-04-27 16:16:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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];
|
2016-01-11 17:04:21 +00:00
|
|
|
if (SkCommandLineFlags::ShouldSkip(FLAGS_match, path.c_str())) {
|
|
|
|
continue;
|
|
|
|
}
|
2015-04-01 19:09:17 +00:00
|
|
|
SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str()));
|
|
|
|
SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded));
|
|
|
|
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();
|
|
|
|
switch (alphaType) {
|
|
|
|
case kOpaque_SkAlphaType:
|
|
|
|
// We only need to test one alpha type (opaque).
|
|
|
|
fCurrentColorType++;
|
|
|
|
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();
|
|
|
|
SkAutoMalloc storage(info.getSafeSize(rowBytes));
|
|
|
|
|
|
|
|
// Used if fCurrentColorType is kIndex_8_SkColorType
|
|
|
|
int colorCount = 256;
|
|
|
|
SkPMColor colors[256];
|
|
|
|
|
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(
|
2015-08-27 14:41:13 +00:00
|
|
|
info, storage.get(), rowBytes, nullptr, colors,
|
2015-04-02 20:22:38 +00:00
|
|
|
&colorCount);
|
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-01-07 22:20:20 +00:00
|
|
|
encoded, 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];
|
|
|
|
if (SkCommandLineFlags::ShouldSkip(FLAGS_match, path.c_str())) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str()));
|
|
|
|
SkAutoTDelete<SkAndroidCodec> codec(SkAndroidCodec::NewFromData(encoded));
|
|
|
|
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++;
|
|
|
|
if (10 * sampleSize > SkTMin(codec->getInfo().width(), codec->getInfo().height())) {
|
|
|
|
// Avoid benchmarking scaled decodes of already small images.
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return new AndroidCodecBench(SkOSPath::Basename(path.c_str()), encoded, sampleSize);
|
|
|
|
}
|
|
|
|
fCurrentSampleSize = 0;
|
|
|
|
}
|
|
|
|
|
2015-09-22 18:56:16 +00:00
|
|
|
// Run the BRDBenches
|
|
|
|
// We will benchmark multiple BRD strategies.
|
2015-10-05 18:03:34 +00:00
|
|
|
static const struct {
|
2015-11-06 16:56:32 +00:00
|
|
|
SkBitmapRegionDecoder::Strategy fStrategy;
|
2015-11-10 22:52:13 +00:00
|
|
|
const char* fName;
|
2015-10-05 18:03:34 +00:00
|
|
|
} strategies[] = {
|
2015-11-10 22:52:13 +00:00
|
|
|
{ SkBitmapRegionDecoder::kCanvas_Strategy, "BRD_canvas" },
|
2015-11-06 16:56:32 +00:00
|
|
|
{ SkBitmapRegionDecoder::kAndroidCodec_Strategy, "BRD_android_codec" },
|
2015-09-22 18:56:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// 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++) {
|
|
|
|
const SkString& path = fImages[fCurrentBRDImage];
|
|
|
|
if (SkCommandLineFlags::ShouldSkip(FLAGS_match, path.c_str())) {
|
|
|
|
continue;
|
|
|
|
}
|
2015-09-22 18:56:16 +00:00
|
|
|
while (fCurrentBRDStrategy < (int) SK_ARRAY_COUNT(strategies)) {
|
2015-10-05 18:03:34 +00:00
|
|
|
fSourceType = "image";
|
|
|
|
fBenchType = strategies[fCurrentBRDStrategy].fName;
|
2015-10-15 14:51:28 +00:00
|
|
|
|
2015-11-06 16:56:32 +00:00
|
|
|
const SkBitmapRegionDecoder::Strategy strategy =
|
2015-10-15 14:51:28 +00:00
|
|
|
strategies[fCurrentBRDStrategy].fStrategy;
|
|
|
|
|
2015-09-22 18:56:16 +00:00
|
|
|
while (fCurrentColorType < fColorTypes.count()) {
|
2016-02-11 14:45:51 +00:00
|
|
|
while (fCurrentSampleSize < (int) SK_ARRAY_COUNT(brdSampleSizes)) {
|
2015-09-22 18:56:16 +00:00
|
|
|
while (fCurrentSubsetType <= kLastSingle_SubsetType) {
|
2015-10-15 14:51:28 +00:00
|
|
|
|
2015-09-22 18:56:16 +00:00
|
|
|
SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str()));
|
|
|
|
const SkColorType colorType = fColorTypes[fCurrentColorType];
|
2016-02-11 14:45:51 +00:00
|
|
|
uint32_t sampleSize = brdSampleSizes[fCurrentSampleSize];
|
2015-09-22 18:56:16 +00:00
|
|
|
int currentSubsetType = fCurrentSubsetType++;
|
|
|
|
|
|
|
|
int width = 0;
|
|
|
|
int height = 0;
|
|
|
|
if (!valid_brd_bench(encoded.get(), strategy, colorType, sampleSize,
|
|
|
|
minOutputSize, &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);
|
|
|
|
break;
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
return new BitmapRegionDecoderBench(basename.c_str(), encoded.get(),
|
|
|
|
strategy, colorType, sampleSize, subset);
|
|
|
|
}
|
|
|
|
fCurrentSubsetType = 0;
|
2016-02-11 14:45:51 +00:00
|
|
|
fCurrentSampleSize++;
|
2015-09-22 18:56:16 +00:00
|
|
|
}
|
2016-02-11 14:45:51 +00:00
|
|
|
fCurrentSampleSize = 0;
|
2015-09-22 18:56:16 +00:00
|
|
|
fCurrentColorType++;
|
|
|
|
}
|
|
|
|
fCurrentColorType = 0;
|
|
|
|
fCurrentBRDStrategy++;
|
|
|
|
}
|
|
|
|
fCurrentBRDStrategy = 0;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
void fillCurrentOptions(ResultsWriter* log) const {
|
|
|
|
log->configOption("source_type", fSourceType);
|
2014-09-10 19:19:30 +00:00
|
|
|
log->configOption("bench_type", fBenchType);
|
2014-08-01 14:46:52 +00:00
|
|
|
if (0 == strcmp(fSourceType, "skp")) {
|
|
|
|
log->configOption("clip",
|
|
|
|
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
|
2014-08-01 14:46:52 +00:00
|
|
|
log->configOption("scale", SkStringPrintf("%.2g", fScales[fCurrentScale]).c_str());
|
2014-11-21 14:19:36 +00:00
|
|
|
if (fCurrentUseMPD > 0) {
|
|
|
|
SkASSERT(1 == fCurrentUseMPD || 2 == fCurrentUseMPD);
|
|
|
|
log->configOption("multi_picture_draw", fUseMPDs[fCurrentUseMPD-1] ? "true" : "false");
|
|
|
|
}
|
2014-08-01 14:46:52 +00:00
|
|
|
}
|
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")) {
|
|
|
|
log->metric("bytes", fSKPBytes);
|
|
|
|
log->metric("ops", fSKPOps);
|
|
|
|
}
|
2014-08-01 14:46:52 +00:00
|
|
|
}
|
|
|
|
|
2014-07-31 19:13:48 +00:00
|
|
|
private:
|
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
|
|
|
};
|
|
|
|
|
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;
|
2014-11-21 14:19:36 +00:00
|
|
|
SkTArray<bool> fUseMPDs;
|
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
|
|
|
|
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
|
|
|
double fSKPBytes, fSKPOps;
|
|
|
|
|
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, ...
|
|
|
|
int fCurrentRecording;
|
2014-08-01 14:46:52 +00:00
|
|
|
int fCurrentScale;
|
|
|
|
int fCurrentSKP;
|
2014-11-21 14:19:36 +00:00
|
|
|
int fCurrentUseMPD;
|
2015-04-01 19:09:17 +00:00
|
|
|
int fCurrentCodec;
|
2016-02-11 14:45:51 +00:00
|
|
|
int fCurrentAndroidCodec;
|
2015-09-22 18:56:16 +00:00
|
|
|
int fCurrentBRDImage;
|
2015-02-13 17:05:41 +00:00
|
|
|
int fCurrentColorType;
|
2016-01-07 22:20:20 +00:00
|
|
|
int fCurrentAlphaType;
|
2015-06-09 20:56:10 +00:00
|
|
|
int fCurrentSubsetType;
|
2015-09-22 18:56:16 +00:00
|
|
|
int fCurrentBRDStrategy;
|
2016-02-11 14:45:51 +00:00
|
|
|
int fCurrentSampleSize;
|
2015-04-27 16:16:57 +00:00
|
|
|
int fCurrentAnimSKP;
|
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() {
|
|
|
|
struct Loop {
|
|
|
|
static void forever(void*) {
|
|
|
|
for (;;) {
|
|
|
|
static const int kSec = 1200;
|
|
|
|
#if defined(SK_BUILD_FOR_WIN)
|
|
|
|
Sleep(kSec * 1000);
|
|
|
|
#else
|
|
|
|
sleep(kSec);
|
|
|
|
#endif
|
|
|
|
SkDebugf("\nBenchmarks still running...\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
static SkThread* intentionallyLeaked = new SkThread(Loop::forever);
|
|
|
|
intentionallyLeaked->start();
|
|
|
|
}
|
|
|
|
|
2014-11-13 16:06:40 +00:00
|
|
|
int nanobench_main();
|
2014-07-22 17:15:34 +00:00
|
|
|
int nanobench_main() {
|
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
|
|
|
|
2014-08-13 17:46:31 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2015-05-22 21:01:46 +00:00
|
|
|
GrContextOptions grContextOpts;
|
2014-08-13 19:06:26 +00:00
|
|
|
grContextOpts.fDrawPathToCompressedTexture = FLAGS_gpuCompressAlphaMasks;
|
2015-08-26 20:07:48 +00:00
|
|
|
gGrFactory.reset(new GrContextFactory(grContextOpts));
|
2014-08-13 17:46:31 +00:00
|
|
|
#endif
|
|
|
|
|
2014-10-24 17:40:50 +00:00
|
|
|
if (FLAGS_veryVerbose) {
|
|
|
|
FLAGS_verbose = true;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-26 20:07:48 +00:00
|
|
|
SkAutoTDelete<ResultsWriter> log(new ResultsWriter);
|
2014-07-14 18:30:37 +00:00
|
|
|
if (!FLAGS_outResultsFile.isEmpty()) {
|
2016-01-20 17:53:59 +00:00
|
|
|
#if defined(SK_RELEASE)
|
2015-08-26 20:07:48 +00:00
|
|
|
log.reset(new NanoJSONResultsWriter(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
|
|
|
}
|
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) {
|
|
|
|
log->property(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;
|
|
|
|
}
|
2014-08-20 18:45:00 +00:00
|
|
|
for (int i = 1; i < FLAGS_key.count(); i += 2) {
|
|
|
|
log->key(FLAGS_key[i-1], FLAGS_key[i]);
|
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
|
|
|
}
|
|
|
|
|
2016-01-28 14:05:43 +00:00
|
|
|
SkTArray<Config> configs;
|
2014-07-22 20:09:05 +00:00
|
|
|
create_configs(&configs);
|
|
|
|
|
2016-02-09 15:18:08 +00:00
|
|
|
#ifdef THERMAL_MANAGER_SUPPORTED
|
|
|
|
int tmEnabled, tmThreshold, tmSleepTimeMs, tmTimeoutMs;
|
|
|
|
if (4 != sscanf(FLAGS_useThermalManager[0], "%d,%d,%d,%d",
|
|
|
|
&tmEnabled, &tmThreshold, &tmSleepTimeMs, &tmTimeoutMs)) {
|
|
|
|
SkDebugf("Can't parse %s from --useThermalManager.\n", FLAGS_useThermalManager[0]);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
ThermalManager tm(tmThreshold, tmSleepTimeMs, tmTimeoutMs);
|
|
|
|
#endif
|
|
|
|
|
2016-01-04 19:35:43 +00:00
|
|
|
if (FLAGS_keepAlive) {
|
|
|
|
start_keepalive();
|
|
|
|
}
|
|
|
|
|
2014-10-14 15:40:43 +00:00
|
|
|
int runs = 0;
|
2014-08-01 14:46:52 +00:00
|
|
|
BenchmarkStream benchStream;
|
|
|
|
while (Benchmark* b = benchStream.next()) {
|
2014-07-31 19:13:48 +00:00
|
|
|
SkAutoTDelete<Benchmark> bench(b);
|
2014-09-10 19:05:59 +00:00
|
|
|
if (SkCommandLineFlags::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()) {
|
2014-09-10 19:05:59 +00:00
|
|
|
log->bench(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) {
|
2016-02-09 15:18:08 +00:00
|
|
|
#ifdef THERMAL_MANAGER_SUPPORTED
|
|
|
|
if (tmEnabled && !tm.coolOffIfNecessary()) {
|
|
|
|
SkDebugf("Could not cool off, timings will be throttled\n");
|
|
|
|
}
|
|
|
|
#endif
|
2015-06-26 15:12:46 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2015-10-28 18:36:30 +00:00
|
|
|
if (FLAGS_ms) {
|
|
|
|
samples.reset();
|
|
|
|
auto stop = now_ms() + FLAGS_ms;
|
|
|
|
do {
|
|
|
|
samples.push_back(time(loops, bench, target) / loops);
|
|
|
|
} 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++) {
|
2015-06-26 15:12:46 +00:00
|
|
|
samples[s] = time(loops, bench, target) / loops;
|
2015-06-26 02:17:08 +00:00
|
|
|
}
|
|
|
|
}
|
2014-06-25 21:08:00 +00:00
|
|
|
|
2015-12-02 17:05:37 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
SkTArray<SkString> keys;
|
|
|
|
SkTArray<double> values;
|
|
|
|
bool gpuStatsDump = FLAGS_gpuStatsDump && Benchmark::kGPU_Backend == configs[i].backend;
|
|
|
|
if (gpuStatsDump) {
|
|
|
|
// TODO cache stats
|
|
|
|
bench->getGpuStats(canvas, &keys, &values);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
if (kFailedLoops == loops) {
|
2014-08-04 20:57:39 +00:00
|
|
|
// Can't be timed. A warning note has already been printed.
|
2015-06-26 15:12:46 +00:00
|
|
|
cleanup_run(target);
|
2014-07-15 21:56:37 +00:00
|
|
|
continue;
|
|
|
|
}
|
2014-07-14 18:30:37 +00:00
|
|
|
|
2015-06-26 02:17:08 +00:00
|
|
|
Stats stats(samples);
|
2014-08-20 18:45:00 +00:00
|
|
|
log->config(config);
|
2014-09-10 19:05:59 +00:00
|
|
|
log->configOption("name", bench->getName());
|
2014-08-20 18:45:00 +00:00
|
|
|
benchStream.fillCurrentOptions(log.get());
|
2015-06-26 15:12:46 +00:00
|
|
|
target->fillOptions(log.get());
|
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
|
|
|
log->metric("min_ms", stats.min);
|
2016-01-11 19:28:26 +00:00
|
|
|
log->metric("median_ms", stats.median);
|
2015-12-02 17:05:37 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
if (gpuStatsDump) {
|
|
|
|
// dump to json, only SKPBench currently returns valid keys / values
|
|
|
|
SkASSERT(keys.count() == values.count());
|
|
|
|
for (int i = 0; i < keys.count(); i++) {
|
|
|
|
log->metric(keys[i].c_str(), values[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-10-14 15:40:43 +00:00
|
|
|
if (runs++ % FLAGS_flushEvery == 0) {
|
|
|
|
log->flush();
|
|
|
|
}
|
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 = " ";
|
|
|
|
const double stddev_percent = 100 * sqrt(stats.var) / stats.mean;
|
|
|
|
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);
|
2014-06-25 21:08:00 +00:00
|
|
|
} else {
|
|
|
|
const double stddev_percent = 100 * sqrt(stats.var) / stats.mean;
|
2015-04-30 14:11:22 +00:00
|
|
|
SkDebugf("%4d/%-4dMB\t%d\t%s\t%s\t%s\t%s\t%.0f%%\t%s\t%s\t%s\n"
|
|
|
|
, 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
|
|
|
|
2015-02-03 05:19:50 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2015-12-02 17:05:37 +00:00
|
|
|
if (FLAGS_gpuStats && Benchmark::kGPU_Backend == configs[i].backend) {
|
2015-12-10 14:28:13 +00:00
|
|
|
GrContext* context = gGrFactory->get(configs[i].ctxType,
|
Add config options to run different GPU APIs to dm and nanobench
Add extended config specification form that can be used to run different
gpu backend with different APIs.
The configs can be specified with the form:
gpu(api=string,dit=bool,nvpr=bool,samples=int)
This replaces and removes the --gpuAPI flag.
All existing configs should still work.
Adds following documentation:
out/Debug/dm --help config
Flags:
--config: type: string default: 565 8888 gpu nonrendering
Options: 565 8888 debug gpu gpudebug gpudft gpunull msaa16 msaa4
nonrendering null nullgpu nvprmsaa16 nvprmsaa4 pdf pdf_poppler skp svg
xps or use extended form 'backend(option=value,...)'.
Extended form: 'backend(option=value,...)'
Possible backends and options:
gpu(api=string,dit=bool,nvpr=bool,samples=int) GPU backend
api type: string default: native.
Select graphics API to use with gpu backend.
Options:
native Use platform default OpenGL or OpenGL ES backend.
gl Use OpenGL.
gles Use OpenGL ES.
debug Use debug OpenGL.
null Use null OpenGL.
dit type: bool default: false.
Use device independent text.
nvpr type: bool default: false.
Use NV_path_rendering OpenGL and OpenGL ES extension.
samples type: int default: 0.
Use multisampling with N samples.
Predefined configs:
gpu = gpu()
msaa4 = gpu(samples=4)
msaa16 = gpu(samples=16)
nvprmsaa4 = gpu(nvpr=true,samples=4)
nvprmsaa16 = gpu(nvpr=true,samples=16)
gpudft = gpu(dit=true)
gpudebug = gpu(api=debug)
gpunull = gpu(api=null)
debug = gpu(api=debug)
nullgpu = gpu(api=null)
BUG=skia:2992
Committed: https://skia.googlesource.com/skia/+/e13ca329fca4c28cf4e078561f591ab27b743d23
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1490113005
Committed: https://skia.googlesource.com/skia/+/c8b4336444e7b90382e04e33665fb3b8490b825b
Committed: https://skia.googlesource.com/skia/+/9ebc3f0ee6db215dde461dc4777d85988cf272dd
Review URL: https://codereview.chromium.org/1490113005
2015-12-23 09:33:00 +00:00
|
|
|
configs[i].ctxOptions);
|
2015-12-10 14:28:13 +00:00
|
|
|
context->printCacheStats();
|
|
|
|
context->printGpuStats();
|
2014-10-24 17:40:50 +00:00
|
|
|
}
|
|
|
|
#endif
|
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);
|
2014-06-25 21:08:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-04 18:47:02 +00:00
|
|
|
log->bench("memory_usage", 0,0);
|
|
|
|
log->config("meta");
|
|
|
|
log->metric("max_rss_mb", sk_tools::getMaxResidentSetSizeMB());
|
|
|
|
|
2015-03-26 17:41:02 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
// Make sure we clean up the global GrContextFactory here, otherwise we might race with the
|
|
|
|
// SkEventTracer destructor
|
2015-08-27 14:41:13 +00:00
|
|
|
gGrFactory.reset(nullptr);
|
2015-03-26 17:41:02 +00:00
|
|
|
#endif
|
|
|
|
|
2014-06-25 21:08:00 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-11-13 16:06:40 +00:00
|
|
|
#if !defined SK_BUILD_FOR_IOS
|
|
|
|
int main(int argc, char** argv) {
|
|
|
|
SkCommandLineFlags::Parse(argc, argv);
|
|
|
|
return nanobench_main();
|
|
|
|
}
|
|
|
|
#endif
|