2011-07-28 14:26:00 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2011 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
2011-08-19 17:22:05 +00:00
|
|
|
|
2013-09-10 19:23:38 +00:00
|
|
|
#include "BenchTimer.h"
|
2013-12-03 18:16:48 +00:00
|
|
|
#include "ResultsWriter.h"
|
2012-09-07 15:21:18 +00:00
|
|
|
#include "SkBenchLogger.h"
|
2011-08-19 17:22:05 +00:00
|
|
|
#include "SkBenchmark.h"
|
2013-08-29 12:40:26 +00:00
|
|
|
#include "SkBitmapDevice.h"
|
2009-01-05 03:34:50 +00:00
|
|
|
#include "SkCanvas.h"
|
2013-09-10 19:42:07 +00:00
|
|
|
#include "SkColorPriv.h"
|
2013-07-24 17:24:23 +00:00
|
|
|
#include "SkCommandLineFlags.h"
|
2014-02-04 14:02:44 +00:00
|
|
|
#include "SkData.h"
|
2012-04-16 19:11:17 +00:00
|
|
|
#include "SkDeferredCanvas.h"
|
2014-02-03 14:48:17 +00:00
|
|
|
#include "SkGMBench.h"
|
2009-01-28 00:56:29 +00:00
|
|
|
#include "SkGraphics.h"
|
2009-01-07 11:47:57 +00:00
|
|
|
#include "SkImageEncoder.h"
|
2013-09-10 19:23:38 +00:00
|
|
|
#include "SkOSFile.h"
|
2009-03-31 03:48:49 +00:00
|
|
|
#include "SkPicture.h"
|
2009-01-05 03:34:50 +00:00
|
|
|
#include "SkString.h"
|
2014-02-04 14:02:44 +00:00
|
|
|
#include "SkSurface.h"
|
2012-07-20 23:03:42 +00:00
|
|
|
|
2013-11-20 13:15:40 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
#include "GrContext.h"
|
|
|
|
#include "GrContextFactory.h"
|
|
|
|
#include "GrRenderTarget.h"
|
|
|
|
#include "SkGpuDevice.h"
|
|
|
|
#include "gl/GrGLDefines.h"
|
|
|
|
#else
|
|
|
|
class GrContext;
|
|
|
|
#endif // SK_SUPPORT_GPU
|
|
|
|
|
2013-09-13 20:39:50 +00:00
|
|
|
#include <limits>
|
|
|
|
|
2014-02-03 14:48:17 +00:00
|
|
|
// Note that ~SkTDArray is not virtual. This inherits privately to bar using this as a SkTDArray*.
|
|
|
|
class RefCntArray : private SkTDArray<SkRefCnt*> {
|
|
|
|
public:
|
|
|
|
SkRefCnt** append() { return this->INHERITED::append(); }
|
|
|
|
~RefCntArray() { this->unrefAll(); }
|
|
|
|
private:
|
|
|
|
typedef SkTDArray<SkRefCnt*> INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
class GMBenchFactory : public SkBenchmarkFactory {
|
|
|
|
public:
|
|
|
|
GMBenchFactory(const skiagm::GMRegistry* gmreg)
|
|
|
|
: fGMFactory(gmreg->factory()) {
|
|
|
|
fSelfRegistry = SkNEW_ARGS(BenchRegistry, (this));
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~GMBenchFactory() { SkDELETE(fSelfRegistry); }
|
|
|
|
|
|
|
|
virtual SkBenchmark* operator()() const SK_OVERRIDE {
|
|
|
|
skiagm::GM* gm = fGMFactory(NULL);
|
2014-02-07 21:13:11 +00:00
|
|
|
gm->setMode(skiagm::GM::kBench_Mode);
|
2014-02-03 14:48:17 +00:00
|
|
|
return SkNEW_ARGS(SkGMBench, (gm));
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
skiagm::GMRegistry::Factory fGMFactory;
|
|
|
|
BenchRegistry* fSelfRegistry;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void register_gm_benches() {
|
|
|
|
static bool gOnce;
|
|
|
|
static RefCntArray gGMBenchFactories;
|
|
|
|
|
|
|
|
if (!gOnce) {
|
|
|
|
const skiagm::GMRegistry* gmreg = skiagm::GMRegistry::Head();
|
|
|
|
while (gmreg) {
|
|
|
|
skiagm::GM* gm = gmreg->factory()(NULL);
|
|
|
|
if (NULL != gm && skiagm::GM::kAsBench_Flag & gm->getFlags()) {
|
|
|
|
*gGMBenchFactories.append() = SkNEW_ARGS(GMBenchFactory, (gmreg));
|
|
|
|
}
|
|
|
|
SkDELETE(gm);
|
|
|
|
gmreg = gmreg->next();
|
|
|
|
}
|
|
|
|
gOnce = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-10 19:23:38 +00:00
|
|
|
enum BenchMode {
|
|
|
|
kNormal_BenchMode,
|
|
|
|
kDeferred_BenchMode,
|
|
|
|
kDeferredSilent_BenchMode,
|
|
|
|
kRecord_BenchMode,
|
|
|
|
kPictureRecord_BenchMode
|
|
|
|
};
|
2013-09-13 20:11:09 +00:00
|
|
|
const char* BenchMode_Name[] = {
|
|
|
|
"normal", "deferred", "deferredSilent", "record", "picturerecord"
|
|
|
|
};
|
2013-08-28 14:17:03 +00:00
|
|
|
|
2013-09-16 19:12:19 +00:00
|
|
|
static const char kDefaultsConfigStr[] = "defaults";
|
|
|
|
|
2012-07-20 23:03:42 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2009-01-05 03:34:50 +00:00
|
|
|
class Iter {
|
|
|
|
public:
|
2013-09-10 19:23:38 +00:00
|
|
|
Iter() : fBench(BenchRegistry::Head()) {}
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2009-01-05 03:34:50 +00:00
|
|
|
SkBenchmark* next() {
|
|
|
|
if (fBench) {
|
|
|
|
BenchRegistry::Factory f = fBench->factory();
|
|
|
|
fBench = fBench->next();
|
2014-02-03 14:48:17 +00:00
|
|
|
return (*f)();
|
2009-01-05 03:34:50 +00:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2011-05-18 18:37:07 +00:00
|
|
|
|
2009-01-05 03:34:50 +00:00
|
|
|
private:
|
|
|
|
const BenchRegistry* fBench;
|
|
|
|
};
|
|
|
|
|
2012-08-13 14:03:31 +00:00
|
|
|
class AutoPrePostDraw {
|
|
|
|
public:
|
|
|
|
AutoPrePostDraw(SkBenchmark* bench) : fBench(bench) {
|
|
|
|
fBench->preDraw();
|
|
|
|
}
|
|
|
|
~AutoPrePostDraw() {
|
|
|
|
fBench->postDraw();
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
SkBenchmark* fBench;
|
|
|
|
};
|
|
|
|
|
2009-01-05 03:34:50 +00:00
|
|
|
static void make_filename(const char name[], SkString* path) {
|
|
|
|
path->set(name);
|
|
|
|
for (int i = 0; name[i]; i++) {
|
|
|
|
switch (name[i]) {
|
|
|
|
case '/':
|
|
|
|
case '\\':
|
|
|
|
case ' ':
|
|
|
|
case ':':
|
|
|
|
path->writable_str()[i] = '-';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-21 03:15:13 +00:00
|
|
|
static void saveFile(const char name[], const char config[], const char dir[],
|
2014-02-04 14:02:44 +00:00
|
|
|
const SkImage* image) {
|
|
|
|
SkAutoTUnref<SkData> data(image->encode(SkImageEncoder::kPNG_Type, 100));
|
|
|
|
if (NULL == data.get()) {
|
2009-01-21 03:15:13 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2013-09-10 19:23:38 +00:00
|
|
|
SkString filename;
|
|
|
|
make_filename(name, &filename);
|
|
|
|
filename.appendf("_%s.png", config);
|
|
|
|
SkString path = SkOSPath::SkPathJoin(dir, filename.c_str());
|
|
|
|
::remove(path.c_str());
|
2014-02-04 14:02:44 +00:00
|
|
|
|
2014-02-06 22:00:58 +00:00
|
|
|
SkFILEWStream stream(path.c_str());
|
2014-02-04 14:02:44 +00:00
|
|
|
stream.write(data->data(), data->size());
|
2009-01-21 03:15:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void performClip(SkCanvas* canvas, int w, int h) {
|
|
|
|
SkRect r;
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2009-01-21 03:15:13 +00:00
|
|
|
r.set(SkIntToScalar(10), SkIntToScalar(10),
|
|
|
|
SkIntToScalar(w*2/3), SkIntToScalar(h*2/3));
|
|
|
|
canvas->clipRect(r, SkRegion::kIntersect_Op);
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2009-01-21 03:15:13 +00:00
|
|
|
r.set(SkIntToScalar(w/3), SkIntToScalar(h/3),
|
|
|
|
SkIntToScalar(w-10), SkIntToScalar(h-10));
|
|
|
|
canvas->clipRect(r, SkRegion::kXOR_Op);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void performRotate(SkCanvas* canvas, int w, int h) {
|
|
|
|
const SkScalar x = SkIntToScalar(w) / 2;
|
|
|
|
const SkScalar y = SkIntToScalar(h) / 2;
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2009-01-21 03:15:13 +00:00
|
|
|
canvas->translate(x, y);
|
|
|
|
canvas->rotate(SkIntToScalar(35));
|
|
|
|
canvas->translate(-x, -y);
|
|
|
|
}
|
|
|
|
|
2009-08-04 01:51:09 +00:00
|
|
|
static void performScale(SkCanvas* canvas, int w, int h) {
|
|
|
|
const SkScalar x = SkIntToScalar(w) / 2;
|
|
|
|
const SkScalar y = SkIntToScalar(h) / 2;
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2009-08-04 01:51:09 +00:00
|
|
|
canvas->translate(x, y);
|
|
|
|
// just enough so we can't take the sprite case
|
|
|
|
canvas->scale(SK_Scalar1 * 99/100, SK_Scalar1 * 99/100);
|
|
|
|
canvas->translate(-x, -y);
|
|
|
|
}
|
|
|
|
|
2014-02-04 14:02:44 +00:00
|
|
|
static SkSurface* make_surface(SkColorType colorType, const SkIPoint& size,
|
|
|
|
SkBenchmark::Backend backend, int sampleCount,
|
|
|
|
GrContext* context) {
|
|
|
|
SkSurface* surface = NULL;
|
|
|
|
SkImageInfo info = SkImageInfo::Make(size.fX, size.fY, colorType,
|
|
|
|
kPremul_SkAlphaType);
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2011-05-17 02:25:05 +00:00
|
|
|
switch (backend) {
|
2013-11-21 06:21:58 +00:00
|
|
|
case SkBenchmark::kRaster_Backend:
|
2014-02-04 14:02:44 +00:00
|
|
|
surface = SkSurface::NewRaster(info);
|
|
|
|
surface->getCanvas()->clear(SK_ColorWHITE);
|
2011-05-17 02:25:05 +00:00
|
|
|
break;
|
2012-08-02 14:03:32 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2013-11-21 06:21:58 +00:00
|
|
|
case SkBenchmark::kGPU_Backend: {
|
2014-02-04 14:02:44 +00:00
|
|
|
surface = SkSurface::NewRenderTarget(context, info, sampleCount);
|
2011-05-17 02:25:05 +00:00
|
|
|
break;
|
2013-02-22 16:13:16 +00:00
|
|
|
}
|
2012-08-02 14:03:32 +00:00
|
|
|
#endif
|
2013-11-21 06:21:58 +00:00
|
|
|
case SkBenchmark::kPDF_Backend:
|
2011-05-17 02:25:05 +00:00
|
|
|
default:
|
2013-08-22 15:37:26 +00:00
|
|
|
SkDEBUGFAIL("unsupported");
|
2011-05-17 02:25:05 +00:00
|
|
|
}
|
2014-02-04 14:02:44 +00:00
|
|
|
return surface;
|
2011-05-17 02:25:05 +00:00
|
|
|
}
|
|
|
|
|
2013-02-22 16:13:16 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
GrContextFactory gContextFactory;
|
|
|
|
typedef GrContextFactory::GLContextType GLContextType;
|
2013-09-10 19:23:38 +00:00
|
|
|
static const GLContextType kNative = GrContextFactory::kNative_GLContextType;
|
2014-01-26 20:51:00 +00:00
|
|
|
static const GLContextType kNVPR = GrContextFactory::kNVPR_GLContextType;
|
2013-09-10 19:23:38 +00:00
|
|
|
#if SK_ANGLE
|
|
|
|
static const GLContextType kANGLE = GrContextFactory::kANGLE_GLContextType;
|
|
|
|
#endif
|
|
|
|
static const GLContextType kDebug = GrContextFactory::kDebug_GLContextType;
|
|
|
|
static const GLContextType kNull = GrContextFactory::kNull_GLContextType;
|
2013-02-22 16:13:16 +00:00
|
|
|
#else
|
|
|
|
typedef int GLContextType;
|
2013-09-10 19:23:38 +00:00
|
|
|
static const GLContextType kNative = 0, kANGLE = 0, kDebug = 0, kNull = 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef SK_DEBUG
|
|
|
|
static const bool kIsDebug = true;
|
|
|
|
#else
|
|
|
|
static const bool kIsDebug = false;
|
2013-02-22 16:13:16 +00:00
|
|
|
#endif
|
|
|
|
|
2013-09-10 19:23:38 +00:00
|
|
|
static const struct Config {
|
2014-02-04 14:02:44 +00:00
|
|
|
SkColorType fColorType;
|
2013-09-10 19:23:38 +00:00
|
|
|
const char* name;
|
|
|
|
int sampleCount;
|
2013-11-21 06:21:58 +00:00
|
|
|
SkBenchmark::Backend backend;
|
2013-09-10 19:23:38 +00:00
|
|
|
GLContextType contextType;
|
|
|
|
bool runByDefault;
|
2009-01-19 20:08:35 +00:00
|
|
|
} gConfigs[] = {
|
2014-02-04 14:02:44 +00:00
|
|
|
{ kPMColor_SkColorType, "NONRENDERING", 0, SkBenchmark::kNonRendering_Backend, kNative, true},
|
|
|
|
{ kPMColor_SkColorType, "8888", 0, SkBenchmark::kRaster_Backend, kNative, true},
|
|
|
|
{ kRGB_565_SkColorType, "565", 0, SkBenchmark::kRaster_Backend, kNative, true},
|
2012-08-02 14:03:32 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2014-02-04 14:02:44 +00:00
|
|
|
{ kPMColor_SkColorType, "GPU", 0, SkBenchmark::kGPU_Backend, kNative, true},
|
|
|
|
{ kPMColor_SkColorType, "MSAA4", 4, SkBenchmark::kGPU_Backend, kNative, false},
|
|
|
|
{ kPMColor_SkColorType, "MSAA16", 16, SkBenchmark::kGPU_Backend, kNative, false},
|
|
|
|
{ kPMColor_SkColorType, "NVPRMSAA4", 4, SkBenchmark::kGPU_Backend, kNVPR, true},
|
|
|
|
{ kPMColor_SkColorType, "NVPRMSAA16", 16, SkBenchmark::kGPU_Backend, kNVPR, false},
|
2012-03-28 16:19:11 +00:00
|
|
|
#if SK_ANGLE
|
2014-02-04 14:02:44 +00:00
|
|
|
{ kPMColor_SkColorType, "ANGLE", 0, SkBenchmark::kGPU_Backend, kANGLE, true},
|
2012-08-02 14:03:32 +00:00
|
|
|
#endif // SK_ANGLE
|
2014-02-04 14:02:44 +00:00
|
|
|
{ kPMColor_SkColorType, "Debug", 0, SkBenchmark::kGPU_Backend, kDebug, kIsDebug},
|
|
|
|
{ kPMColor_SkColorType, "NULLGPU", 0, SkBenchmark::kGPU_Backend, kNull, true},
|
2012-08-02 14:03:32 +00:00
|
|
|
#endif // SK_SUPPORT_GPU
|
2009-01-19 20:08:35 +00:00
|
|
|
};
|
|
|
|
|
2013-09-10 19:23:38 +00:00
|
|
|
DEFINE_string(outDir, "", "If given, image of each bench will be put in outDir.");
|
|
|
|
DEFINE_string(timers, "cg", "Timers to display. "
|
|
|
|
"Options: w(all) W(all, truncated) c(pu) C(pu, truncated) g(pu)");
|
|
|
|
|
|
|
|
DEFINE_bool(rotate, false, "Rotate canvas before bench run?");
|
|
|
|
DEFINE_bool(scale, false, "Scale canvas before bench run?");
|
|
|
|
DEFINE_bool(clip, false, "Clip canvas before bench run?");
|
|
|
|
|
|
|
|
DEFINE_bool(forceAA, true, "Force anti-aliasing?");
|
|
|
|
DEFINE_bool(forceFilter, false, "Force bitmap filtering?");
|
|
|
|
DEFINE_string(forceDither, "default", "Force dithering: true, false, or default?");
|
|
|
|
DEFINE_bool(forceBlend, false, "Force alpha blending?");
|
|
|
|
|
|
|
|
DEFINE_int32(gpuCacheBytes, -1, "GPU cache size limit in bytes. 0 to disable cache.");
|
|
|
|
DEFINE_int32(gpuCacheCount, -1, "GPU cache size limit in object count. 0 to disable cache.");
|
|
|
|
|
2014-01-23 17:21:19 +00:00
|
|
|
DEFINE_bool2(leaks, l, false, "show leaked ref cnt'd objects.");
|
2013-09-10 19:23:38 +00:00
|
|
|
DEFINE_string(match, "", "[~][^]substring[$] [...] of test name to run.\n"
|
|
|
|
"Multiple matches may be separated by spaces.\n"
|
|
|
|
"~ causes a matching test to always be skipped\n"
|
|
|
|
"^ requires the start of the test to match\n"
|
|
|
|
"$ requires the end of the test to match\n"
|
|
|
|
"^ and $ requires an exact match\n"
|
|
|
|
"If a test does not match any list entry,\n"
|
|
|
|
"it is skipped unless some list entry starts with ~\n");
|
|
|
|
DEFINE_string(mode, "normal",
|
|
|
|
"normal: draw to a normal canvas;\n"
|
|
|
|
"deferred: draw to a deferred canvas;\n"
|
|
|
|
"deferredSilent: deferred with silent playback;\n"
|
|
|
|
"record: draw to an SkPicture;\n"
|
|
|
|
"picturerecord: draw from an SkPicture to an SkPicture.\n");
|
2013-09-16 19:12:19 +00:00
|
|
|
DEFINE_string(config, kDefaultsConfigStr,
|
|
|
|
"Run configs given. By default, runs the configs marked \"runByDefault\" in gConfigs.");
|
2013-09-10 19:23:38 +00:00
|
|
|
DEFINE_string(logFile, "", "Also write stdout here.");
|
2013-09-13 20:11:09 +00:00
|
|
|
DEFINE_int32(minMs, 20, "Shortest time we'll allow a benchmark to run.");
|
|
|
|
DEFINE_int32(maxMs, 4000, "Longest time we'll allow a benchmark to run.");
|
|
|
|
DEFINE_double(error, 0.01,
|
|
|
|
"Ratio of subsequent bench measurements must drop within 1±error to converge.");
|
2013-09-10 19:23:38 +00:00
|
|
|
DEFINE_string(timeFormat, "%9.2f", "Format to print results, in milliseconds per 1000 loops.");
|
2013-09-13 20:11:09 +00:00
|
|
|
DEFINE_bool2(verbose, v, false, "Print more.");
|
2013-12-31 14:29:52 +00:00
|
|
|
DEFINE_string2(resourcePath, i, "resources", "directory for test resources.");
|
2013-12-03 18:16:48 +00:00
|
|
|
DEFINE_string(outResultsFile, "", "If given, the results will be written to the file in JSON format.");
|
2013-09-13 20:11:09 +00:00
|
|
|
|
|
|
|
// Has this bench converged? First arguments are milliseconds / loop iteration,
|
|
|
|
// last is overall runtime in milliseconds.
|
|
|
|
static bool HasConverged(double prevPerLoop, double currPerLoop, double currRaw) {
|
|
|
|
if (currRaw < FLAGS_minMs) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
const double low = 1 - FLAGS_error, high = 1 + FLAGS_error;
|
|
|
|
const double ratio = currPerLoop / prevPerLoop;
|
|
|
|
return low < ratio && ratio < high;
|
|
|
|
}
|
2012-04-03 13:28:57 +00:00
|
|
|
|
2012-10-02 18:33:14 +00:00
|
|
|
int tool_main(int argc, char** argv);
|
|
|
|
int tool_main(int argc, char** argv) {
|
2014-02-03 14:48:17 +00:00
|
|
|
register_gm_benches();
|
2014-01-23 17:21:19 +00:00
|
|
|
SkCommandLineFlags::Parse(argc, argv);
|
2013-01-15 20:37:04 +00:00
|
|
|
#if SK_ENABLE_INST_COUNT
|
2014-01-23 17:21:19 +00:00
|
|
|
if (FLAGS_leaks) {
|
|
|
|
gPrintInstCount = true;
|
|
|
|
}
|
2012-08-14 13:15:44 +00:00
|
|
|
#endif
|
2009-01-28 00:56:29 +00:00
|
|
|
SkAutoGraphics ag;
|
2012-08-14 13:15:44 +00:00
|
|
|
|
2013-09-10 19:23:38 +00:00
|
|
|
// First, parse some flags.
|
|
|
|
SkBenchLogger logger;
|
|
|
|
if (FLAGS_logFile.count()) {
|
|
|
|
logger.SetLogFile(FLAGS_logFile[0]);
|
|
|
|
}
|
2013-07-31 20:00:56 +00:00
|
|
|
|
2013-12-03 18:16:48 +00:00
|
|
|
LoggerResultsWriter logWriter(logger, FLAGS_timeFormat[0]);
|
|
|
|
MultiResultsWriter writer;
|
|
|
|
writer.add(&logWriter);
|
|
|
|
SkAutoTDelete<JSONResultsWriter> jsonWriter;
|
|
|
|
if (FLAGS_outResultsFile.count()) {
|
|
|
|
jsonWriter.reset(SkNEW(JSONResultsWriter(FLAGS_outResultsFile[0])));
|
|
|
|
writer.add(jsonWriter.get());
|
|
|
|
}
|
|
|
|
// Instantiate after all the writers have been added to writer so that we
|
|
|
|
// call close() before their destructors are called on the way out.
|
|
|
|
CallEnd<MultiResultsWriter> ender(writer);
|
|
|
|
|
2013-09-10 19:23:38 +00:00
|
|
|
const uint8_t alpha = FLAGS_forceBlend ? 0x80 : 0xFF;
|
|
|
|
SkTriState::State dither = SkTriState::kDefault;
|
|
|
|
for (size_t i = 0; i < 3; i++) {
|
|
|
|
if (strcmp(SkTriState::Name[i], FLAGS_forceDither[0]) == 0) {
|
|
|
|
dither = static_cast<SkTriState::State>(i);
|
|
|
|
}
|
|
|
|
}
|
2013-03-11 20:22:15 +00:00
|
|
|
|
2013-09-10 19:23:38 +00:00
|
|
|
BenchMode benchMode = kNormal_BenchMode;
|
|
|
|
for (size_t i = 0; i < SK_ARRAY_COUNT(BenchMode_Name); i++) {
|
|
|
|
if (strcmp(FLAGS_mode[0], BenchMode_Name[i]) == 0) {
|
|
|
|
benchMode = static_cast<BenchMode>(i);
|
|
|
|
}
|
|
|
|
}
|
2013-03-11 20:22:15 +00:00
|
|
|
|
2012-04-16 18:00:40 +00:00
|
|
|
SkTDArray<int> configs;
|
2013-09-16 19:12:19 +00:00
|
|
|
bool runDefaultConfigs = false;
|
2013-09-10 19:23:38 +00:00
|
|
|
// Try user-given configs first.
|
|
|
|
for (int i = 0; i < FLAGS_config.count(); i++) {
|
2013-10-16 17:48:11 +00:00
|
|
|
for (int j = 0; j < static_cast<int>(SK_ARRAY_COUNT(gConfigs)); ++j) {
|
2013-09-10 19:23:38 +00:00
|
|
|
if (0 == strcmp(FLAGS_config[i], gConfigs[j].name)) {
|
|
|
|
*configs.append() = j;
|
2013-09-16 19:12:19 +00:00
|
|
|
} else if (0 == strcmp(FLAGS_config[i], kDefaultsConfigStr)) {
|
|
|
|
runDefaultConfigs = true;
|
2009-09-02 21:12:42 +00:00
|
|
|
}
|
2009-01-07 11:47:57 +00:00
|
|
|
}
|
|
|
|
}
|
2013-09-10 19:23:38 +00:00
|
|
|
// If there weren't any, fill in with defaults.
|
2013-09-16 19:12:19 +00:00
|
|
|
if (runDefaultConfigs) {
|
2013-10-16 17:48:11 +00:00
|
|
|
for (int i = 0; i < static_cast<int>(SK_ARRAY_COUNT(gConfigs)); ++i) {
|
2013-09-10 19:23:38 +00:00
|
|
|
if (gConfigs[i].runByDefault) {
|
2013-03-19 13:58:55 +00:00
|
|
|
*configs.append() = i;
|
|
|
|
}
|
2012-04-16 18:00:40 +00:00
|
|
|
}
|
|
|
|
}
|
2013-09-10 19:23:38 +00:00
|
|
|
// Filter out things we can't run.
|
|
|
|
if (kNormal_BenchMode != benchMode) {
|
2013-03-15 15:42:15 +00:00
|
|
|
// Non-rendering configs only run in normal mode
|
|
|
|
for (int i = 0; i < configs.count(); ++i) {
|
2013-09-10 19:23:38 +00:00
|
|
|
const Config& config = gConfigs[configs[i]];
|
2013-11-21 06:21:58 +00:00
|
|
|
if (SkBenchmark::kNonRendering_Backend == config.backend) {
|
2013-03-15 15:42:15 +00:00
|
|
|
configs.remove(i, 1);
|
|
|
|
--i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-09-25 21:42:12 +00:00
|
|
|
// Set the resource path.
|
|
|
|
if (!FLAGS_resourcePath.isEmpty()) {
|
|
|
|
SkBenchmark::SetResourcePath(FLAGS_resourcePath[0]);
|
|
|
|
}
|
|
|
|
|
2013-03-19 13:58:55 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
for (int i = 0; i < configs.count(); ++i) {
|
2013-09-10 19:23:38 +00:00
|
|
|
const Config& config = gConfigs[configs[i]];
|
2013-03-19 13:58:55 +00:00
|
|
|
|
2013-11-21 06:21:58 +00:00
|
|
|
if (SkBenchmark::kGPU_Backend == config.backend) {
|
2013-09-10 19:23:38 +00:00
|
|
|
GrContext* context = gContextFactory.get(config.contextType);
|
2013-03-19 13:58:55 +00:00
|
|
|
if (NULL == context) {
|
2013-09-13 20:11:09 +00:00
|
|
|
logger.logError(SkStringPrintf(
|
|
|
|
"Error creating GrContext for config %s. Config will be skipped.\n",
|
|
|
|
config.name));
|
2013-03-19 13:58:55 +00:00
|
|
|
configs.remove(i);
|
|
|
|
--i;
|
|
|
|
continue;
|
|
|
|
}
|
2013-09-10 19:23:38 +00:00
|
|
|
if (config.sampleCount > context->getMaxSampleCount()){
|
2013-09-13 20:11:09 +00:00
|
|
|
logger.logError(SkStringPrintf(
|
|
|
|
"Sample count (%d) for config %s is unsupported. Config will be skipped.\n",
|
|
|
|
config.sampleCount, config.name));
|
2013-03-19 13:58:55 +00:00
|
|
|
configs.remove(i);
|
|
|
|
--i;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-09-10 19:23:38 +00:00
|
|
|
// All flags should be parsed now. Report our settings.
|
|
|
|
if (kIsDebug) {
|
|
|
|
logger.logError("bench was built in Debug mode, so we're going to hide the times."
|
|
|
|
" It's for your own good!\n");
|
|
|
|
}
|
2013-12-03 18:16:48 +00:00
|
|
|
writer.option("mode", FLAGS_mode[0]);
|
|
|
|
writer.option("alpha", SkStringPrintf("0x%02X", alpha).c_str());
|
|
|
|
writer.option("antialias", SkStringPrintf("%d", FLAGS_forceAA).c_str());
|
|
|
|
writer.option("filter", SkStringPrintf("%d", FLAGS_forceFilter).c_str());
|
|
|
|
writer.option("dither", SkTriState::Name[dither]);
|
|
|
|
|
|
|
|
writer.option("rotate", SkStringPrintf("%d", FLAGS_rotate).c_str());
|
|
|
|
writer.option("scale", SkStringPrintf("%d", FLAGS_scale).c_str());
|
|
|
|
writer.option("clip", SkStringPrintf("%d", FLAGS_clip).c_str());
|
2013-09-10 19:23:38 +00:00
|
|
|
|
2011-06-15 17:25:46 +00:00
|
|
|
#if defined(SK_BUILD_FOR_WIN32)
|
2013-12-03 18:16:48 +00:00
|
|
|
writer.option("system", "WIN32");
|
2011-06-15 17:25:46 +00:00
|
|
|
#elif defined(SK_BUILD_FOR_MAC)
|
2013-12-03 18:16:48 +00:00
|
|
|
writer.option("system", "MAC");
|
2011-06-15 17:25:46 +00:00
|
|
|
#elif defined(SK_BUILD_FOR_ANDROID)
|
2013-12-03 18:16:48 +00:00
|
|
|
writer.option("system", "ANDROID");
|
2011-06-15 17:25:46 +00:00
|
|
|
#elif defined(SK_BUILD_FOR_UNIX)
|
2013-12-03 18:16:48 +00:00
|
|
|
writer.option("system", "UNIX");
|
2011-06-15 17:25:46 +00:00
|
|
|
#else
|
2013-12-03 18:16:48 +00:00
|
|
|
writer.option("system", "other");
|
2011-06-15 17:25:46 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(SK_DEBUG)
|
2013-12-03 18:16:48 +00:00
|
|
|
writer.option("build", "DEBUG");
|
|
|
|
#else
|
|
|
|
writer.option("build", "RELEASE");
|
2011-06-15 17:25:46 +00:00
|
|
|
#endif
|
2011-12-13 16:49:49 +00:00
|
|
|
|
2013-09-10 19:23:38 +00:00
|
|
|
// Set texture cache limits if non-default.
|
2013-02-22 19:17:13 +00:00
|
|
|
for (size_t i = 0; i < SK_ARRAY_COUNT(gConfigs); ++i) {
|
2013-02-22 16:13:16 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2013-09-10 19:23:38 +00:00
|
|
|
const Config& config = gConfigs[i];
|
2013-11-21 06:21:58 +00:00
|
|
|
if (SkBenchmark::kGPU_Backend != config.backend) {
|
2013-09-10 19:23:38 +00:00
|
|
|
continue;
|
2013-02-22 16:13:16 +00:00
|
|
|
}
|
2013-09-10 19:23:38 +00:00
|
|
|
GrContext* context = gContextFactory.get(config.contextType);
|
|
|
|
if (NULL == context) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t bytes;
|
|
|
|
int count;
|
|
|
|
context->getTextureCacheLimits(&count, &bytes);
|
|
|
|
if (-1 != FLAGS_gpuCacheBytes) {
|
|
|
|
bytes = static_cast<size_t>(FLAGS_gpuCacheBytes);
|
|
|
|
}
|
|
|
|
if (-1 != FLAGS_gpuCacheCount) {
|
|
|
|
count = FLAGS_gpuCacheCount;
|
|
|
|
}
|
|
|
|
context->setTextureCacheLimits(count, bytes);
|
2013-02-22 16:13:16 +00:00
|
|
|
#endif
|
|
|
|
}
|
2011-10-27 20:44:19 +00:00
|
|
|
|
2013-09-10 19:23:38 +00:00
|
|
|
// Run each bench in each configuration it supports and we asked for.
|
|
|
|
Iter iter;
|
2013-12-03 18:16:48 +00:00
|
|
|
SkBenchmark* bench;
|
2013-09-10 19:23:38 +00:00
|
|
|
while ((bench = iter.next()) != NULL) {
|
|
|
|
SkAutoTUnref<SkBenchmark> benchUnref(bench);
|
|
|
|
if (SkCommandLineFlags::ShouldSkip(FLAGS_match, bench->getName())) {
|
2009-08-04 01:51:09 +00:00
|
|
|
continue;
|
|
|
|
}
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2013-09-10 19:23:38 +00:00
|
|
|
bench->setForceAlpha(alpha);
|
|
|
|
bench->setForceAA(FLAGS_forceAA);
|
|
|
|
bench->setForceFilter(FLAGS_forceFilter);
|
|
|
|
bench->setDither(dither);
|
2012-08-13 14:03:31 +00:00
|
|
|
AutoPrePostDraw appd(bench);
|
|
|
|
|
2013-09-10 19:23:38 +00:00
|
|
|
bool loggedBenchName = false;
|
|
|
|
for (int i = 0; i < configs.count(); ++i) {
|
|
|
|
const int configIndex = configs[i];
|
|
|
|
const Config& config = gConfigs[configIndex];
|
2013-06-03 19:31:07 +00:00
|
|
|
|
2013-11-21 06:21:58 +00:00
|
|
|
if (!bench->isSuitableFor(config.backend)) {
|
2013-09-10 19:23:38 +00:00
|
|
|
continue;
|
2013-03-15 15:42:15 +00:00
|
|
|
}
|
|
|
|
|
2013-02-22 16:13:16 +00:00
|
|
|
GrContext* context = NULL;
|
2012-08-02 14:03:32 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2013-03-07 20:52:59 +00:00
|
|
|
SkGLContextHelper* glContext = NULL;
|
2013-11-21 06:21:58 +00:00
|
|
|
if (SkBenchmark::kGPU_Backend == config.backend) {
|
2013-09-10 19:23:38 +00:00
|
|
|
context = gContextFactory.get(config.contextType);
|
2013-02-22 16:13:16 +00:00
|
|
|
if (NULL == context) {
|
|
|
|
continue;
|
|
|
|
}
|
2013-09-10 19:23:38 +00:00
|
|
|
glContext = gContextFactory.getGLContext(config.contextType);
|
2009-01-19 20:08:35 +00:00
|
|
|
}
|
2012-08-02 14:03:32 +00:00
|
|
|
#endif
|
2014-02-04 14:02:44 +00:00
|
|
|
|
2013-09-10 19:23:38 +00:00
|
|
|
SkAutoTUnref<SkCanvas> canvas;
|
|
|
|
SkPicture recordFrom, recordTo;
|
|
|
|
const SkIPoint dim = bench->getSize();
|
|
|
|
|
|
|
|
const SkPicture::RecordingFlags kRecordFlags =
|
|
|
|
SkPicture::kUsePathBoundsForClip_RecordingFlag;
|
|
|
|
|
2014-02-04 14:02:44 +00:00
|
|
|
SkAutoTUnref<SkSurface> surface;
|
2013-11-21 06:21:58 +00:00
|
|
|
if (SkBenchmark::kNonRendering_Backend != config.backend) {
|
2014-02-04 14:02:44 +00:00
|
|
|
surface.reset(make_surface(config.fColorType,
|
|
|
|
dim,
|
|
|
|
config.backend,
|
|
|
|
config.sampleCount,
|
|
|
|
context));
|
|
|
|
if (!surface.get()) {
|
2013-09-13 20:11:09 +00:00
|
|
|
logger.logError(SkStringPrintf(
|
|
|
|
"Device creation failure for config %s. Will skip.\n", config.name));
|
2013-09-10 19:23:38 +00:00
|
|
|
continue;
|
2013-03-15 15:42:15 +00:00
|
|
|
}
|
|
|
|
|
2013-09-10 19:23:38 +00:00
|
|
|
switch(benchMode) {
|
|
|
|
case kDeferredSilent_BenchMode:
|
|
|
|
case kDeferred_BenchMode:
|
2014-02-04 14:02:44 +00:00
|
|
|
canvas.reset(SkDeferredCanvas::Create(surface.get()));
|
2013-09-10 19:23:38 +00:00
|
|
|
break;
|
|
|
|
case kRecord_BenchMode:
|
|
|
|
canvas.reset(SkRef(recordTo.beginRecording(dim.fX, dim.fY, kRecordFlags)));
|
|
|
|
break;
|
|
|
|
case kPictureRecord_BenchMode:
|
2013-12-03 18:17:16 +00:00
|
|
|
bench->draw(1, recordFrom.beginRecording(dim.fX, dim.fY, kRecordFlags));
|
2013-09-10 19:23:38 +00:00
|
|
|
recordFrom.endRecording();
|
|
|
|
canvas.reset(SkRef(recordTo.beginRecording(dim.fX, dim.fY, kRecordFlags)));
|
|
|
|
break;
|
|
|
|
case kNormal_BenchMode:
|
2014-02-04 14:02:44 +00:00
|
|
|
canvas.reset(SkRef(surface->getCanvas()));
|
2013-09-10 19:23:38 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
SkASSERT(false);
|
2013-06-03 19:31:07 +00:00
|
|
|
}
|
2013-09-10 19:23:38 +00:00
|
|
|
}
|
2011-12-13 16:49:49 +00:00
|
|
|
|
2013-09-10 19:23:38 +00:00
|
|
|
if (NULL != canvas) {
|
|
|
|
canvas->clear(SK_ColorWHITE);
|
|
|
|
if (FLAGS_clip) { performClip(canvas, dim.fX, dim.fY); }
|
|
|
|
if (FLAGS_scale) { performScale(canvas, dim.fX, dim.fY); }
|
|
|
|
if (FLAGS_rotate) { performRotate(canvas, dim.fX, dim.fY); }
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!loggedBenchName) {
|
|
|
|
loggedBenchName = true;
|
2013-12-03 18:16:48 +00:00
|
|
|
writer.bench(bench->getName(), dim.fX, dim.fY);
|
2013-09-10 19:23:38 +00:00
|
|
|
}
|
2012-07-20 23:03:42 +00:00
|
|
|
|
2012-08-02 14:03:32 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2013-09-10 19:23:38 +00:00
|
|
|
SkGLContextHelper* contextHelper = NULL;
|
2013-11-21 06:21:58 +00:00
|
|
|
if (SkBenchmark::kGPU_Backend == config.backend) {
|
2013-09-10 19:23:38 +00:00
|
|
|
contextHelper = gContextFactory.getGLContext(config.contextType);
|
|
|
|
}
|
|
|
|
BenchTimer timer(contextHelper);
|
|
|
|
#else
|
|
|
|
BenchTimer timer;
|
2012-08-02 14:03:32 +00:00
|
|
|
#endif
|
2012-07-02 20:48:51 +00:00
|
|
|
|
2013-09-13 20:39:50 +00:00
|
|
|
double previous = std::numeric_limits<double>::infinity();
|
2013-09-13 20:11:09 +00:00
|
|
|
bool converged = false;
|
2013-10-10 17:33:39 +00:00
|
|
|
|
|
|
|
// variables used to compute loopsPerFrame
|
|
|
|
double frameIntervalTime = 0.0f;
|
|
|
|
int frameIntervalTotalLoops = 0;
|
|
|
|
|
|
|
|
bool frameIntervalComputed = false;
|
|
|
|
int loopsPerFrame = 0;
|
|
|
|
int loopsPerIter = 0;
|
2013-09-13 20:11:09 +00:00
|
|
|
if (FLAGS_verbose) { SkDebugf("%s %s: ", bench->getName(), config.name); }
|
2013-09-10 19:23:38 +00:00
|
|
|
do {
|
2013-10-10 17:33:39 +00:00
|
|
|
// Ramp up 1 -> 2 -> 4 -> 8 -> 16 -> ... -> ~1 billion.
|
|
|
|
loopsPerIter = (loopsPerIter == 0) ? 1 : loopsPerIter * 2;
|
|
|
|
if (loopsPerIter >= (1<<30) || timer.fWall > FLAGS_maxMs) {
|
2013-09-10 19:23:38 +00:00
|
|
|
// If you find it takes more than a billion loops to get up to 20ms of runtime,
|
|
|
|
// you've got a computer clocked at several THz or have a broken benchmark. ;)
|
|
|
|
// "1B ought to be enough for anybody."
|
2013-09-13 20:11:09 +00:00
|
|
|
logger.logError(SkStringPrintf(
|
2013-10-10 17:33:39 +00:00
|
|
|
"\nCan't get %s %s to converge in %dms (%d loops)",
|
|
|
|
bench->getName(), config.name, FLAGS_maxMs, loopsPerIter));
|
2013-09-10 19:23:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((benchMode == kRecord_BenchMode || benchMode == kPictureRecord_BenchMode)) {
|
|
|
|
// Clear the recorded commands so that they do not accumulate.
|
2014-02-04 19:32:37 +00:00
|
|
|
canvas.reset(SkRef(recordTo.beginRecording(dim.fX, dim.fY, kRecordFlags)));
|
2013-09-10 19:23:38 +00:00
|
|
|
}
|
2012-08-23 17:50:06 +00:00
|
|
|
|
2013-09-10 19:23:38 +00:00
|
|
|
timer.start();
|
2013-10-10 17:33:39 +00:00
|
|
|
// Inner loop that allows us to break the run into smaller
|
|
|
|
// chunks (e.g. frames). This is especially useful for the GPU
|
|
|
|
// as we can flush and/or swap buffers to keep the GPU from
|
|
|
|
// queuing up too much work.
|
|
|
|
for (int loopCount = loopsPerIter; loopCount > 0; ) {
|
2013-10-14 15:28:01 +00:00
|
|
|
// Save and restore around each call to draw() to guarantee a pristine canvas.
|
|
|
|
SkAutoCanvasRestore saveRestore(canvas, true/*also save*/);
|
|
|
|
|
2013-12-03 18:17:16 +00:00
|
|
|
int loops;
|
2013-10-10 17:33:39 +00:00
|
|
|
if (frameIntervalComputed && loopCount > loopsPerFrame) {
|
2013-12-03 18:17:16 +00:00
|
|
|
loops = loopsPerFrame;
|
2013-10-10 17:33:39 +00:00
|
|
|
loopCount -= loopsPerFrame;
|
|
|
|
} else {
|
2013-12-03 18:17:16 +00:00
|
|
|
loops = loopCount;
|
2013-10-10 17:33:39 +00:00
|
|
|
loopCount = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (benchMode == kPictureRecord_BenchMode) {
|
|
|
|
recordFrom.draw(canvas);
|
|
|
|
} else {
|
2013-12-03 18:17:16 +00:00
|
|
|
bench->draw(loops, canvas);
|
2013-10-10 17:33:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (kDeferredSilent_BenchMode == benchMode) {
|
|
|
|
static_cast<SkDeferredCanvas*>(canvas.get())->silentFlush();
|
|
|
|
} else if (NULL != canvas) {
|
|
|
|
canvas->flush();
|
|
|
|
}
|
|
|
|
|
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
// swap drawing buffers on each frame to prevent the GPU
|
|
|
|
// from queuing up too much work
|
|
|
|
if (NULL != glContext) {
|
|
|
|
glContext->swapBuffers();
|
|
|
|
}
|
|
|
|
#endif
|
2013-09-10 19:23:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Stop truncated timers before GL calls complete, and stop the full timers after.
|
|
|
|
timer.truncatedEnd();
|
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
if (NULL != glContext) {
|
|
|
|
context->flush();
|
|
|
|
SK_GL(*glContext, Finish());
|
2013-09-10 17:22:43 +00:00
|
|
|
}
|
2013-09-10 19:23:38 +00:00
|
|
|
#endif
|
|
|
|
timer.end();
|
2013-10-10 17:33:39 +00:00
|
|
|
|
2013-10-10 18:48:27 +00:00
|
|
|
// setup the frame interval for subsequent iterations
|
|
|
|
if (!frameIntervalComputed) {
|
2013-10-10 17:33:39 +00:00
|
|
|
frameIntervalTime += timer.fWall;
|
|
|
|
frameIntervalTotalLoops += loopsPerIter;
|
|
|
|
if (frameIntervalTime >= FLAGS_minMs) {
|
|
|
|
frameIntervalComputed = true;
|
|
|
|
loopsPerFrame =
|
2013-10-10 17:50:52 +00:00
|
|
|
(int)(((double)frameIntervalTotalLoops / frameIntervalTime) * FLAGS_minMs);
|
2013-10-10 17:33:39 +00:00
|
|
|
if (loopsPerFrame < 1) {
|
|
|
|
loopsPerFrame = 1;
|
|
|
|
}
|
|
|
|
// SkDebugf(" %s has %d loops in %f ms (normalized to %d)\n",
|
|
|
|
// bench->getName(), frameIntervalTotalLoops,
|
|
|
|
// timer.fWall, loopsPerFrame);
|
|
|
|
}
|
|
|
|
}
|
2013-10-10 18:48:27 +00:00
|
|
|
|
2013-10-10 17:33:39 +00:00
|
|
|
const double current = timer.fWall / loopsPerIter;
|
2013-09-13 20:11:09 +00:00
|
|
|
if (FLAGS_verbose && current > previous) { SkDebugf("↑"); }
|
|
|
|
if (FLAGS_verbose) { SkDebugf("%.3g ", current); }
|
|
|
|
converged = HasConverged(previous, current, timer.fWall);
|
|
|
|
previous = current;
|
|
|
|
} while (!kIsDebug && !converged);
|
|
|
|
if (FLAGS_verbose) { SkDebugf("\n"); }
|
2013-09-10 19:23:38 +00:00
|
|
|
|
2013-11-21 06:21:58 +00:00
|
|
|
if (FLAGS_outDir.count() && SkBenchmark::kNonRendering_Backend != config.backend) {
|
2014-02-04 14:02:44 +00:00
|
|
|
SkAutoTUnref<SkImage> image(surface->newImageSnapshot());
|
|
|
|
if (image.get()) {
|
|
|
|
saveFile(bench->getName(), config.name, FLAGS_outDir[0],
|
|
|
|
image);
|
|
|
|
}
|
2013-09-10 19:23:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (kIsDebug) {
|
|
|
|
// Let's not mislead ourselves by looking at Debug build bench times!
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Normalize to ms per 1000 iterations.
|
2013-10-10 17:33:39 +00:00
|
|
|
const double normalize = 1000.0 / loopsPerIter;
|
2013-09-10 19:23:38 +00:00
|
|
|
const struct { char shortName; const char* longName; double ms; } times[] = {
|
|
|
|
{'w', "msecs", normalize * timer.fWall},
|
|
|
|
{'W', "Wmsecs", normalize * timer.fTruncatedWall},
|
|
|
|
{'c', "cmsecs", normalize * timer.fCpu},
|
|
|
|
{'C', "Cmsecs", normalize * timer.fTruncatedCpu},
|
|
|
|
{'g', "gmsecs", normalize * timer.fGpu},
|
|
|
|
};
|
|
|
|
|
2013-12-03 18:16:48 +00:00
|
|
|
writer.config(config.name);
|
2013-09-10 19:23:38 +00:00
|
|
|
for (size_t i = 0; i < SK_ARRAY_COUNT(times); i++) {
|
|
|
|
if (strchr(FLAGS_timers[0], times[i].shortName) && times[i].ms > 0) {
|
2013-12-03 18:16:48 +00:00
|
|
|
writer.timer(times[i].longName, times[i].ms);
|
2013-06-03 19:31:07 +00:00
|
|
|
}
|
2011-07-14 19:03:58 +00:00
|
|
|
}
|
2009-01-19 20:08:35 +00:00
|
|
|
}
|
2009-01-05 03:34:50 +00:00
|
|
|
}
|
2012-08-02 14:03:32 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2013-02-22 16:13:16 +00:00
|
|
|
gContextFactory.destroyContexts();
|
2012-08-02 14:03:32 +00:00
|
|
|
#endif
|
2009-01-05 03:34:50 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2012-10-02 18:33:14 +00:00
|
|
|
|
2012-11-01 17:43:44 +00:00
|
|
|
#if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
|
2012-10-02 18:33:14 +00:00
|
|
|
int main(int argc, char * const argv[]) {
|
|
|
|
return tool_main(argc, (char**) argv);
|
|
|
|
}
|
|
|
|
#endif
|