Remove benches from DM.

This idea turned out to be more redundant than useful.

BUG=skia:
R=mtklein@google.com

Author: mtklein@chromium.org

Review URL: https://codereview.chromium.org/399463003
This commit is contained in:
mtklein 2014-07-16 14:29:53 -07:00 committed by Commit bot
parent 0b4cc892cb
commit 103ae71cdd
5 changed files with 2 additions and 198 deletions

View File

@ -1,7 +1,6 @@
// Main binary for DM.
// For a high-level overview, please see dm/README.
#include "Benchmark.h"
#include "CrashHandler.h"
#include "SkCommandLineFlags.h"
#include "SkForceLinking.h"
@ -11,7 +10,6 @@
#include "Test.h"
#include "gm.h"
#include "DMBenchTask.h"
#include "DMCpuGMTask.h"
#include "DMGpuGMTask.h"
#include "DMGpuSupport.h"
@ -68,7 +66,6 @@ DEFINE_bool(leaks, false, "Print leaked instance-counted objects at exit?");
DEFINE_string(skps, "", "Directory to read skps from.");
DEFINE_bool(gms, true, "Run GMs?");
DEFINE_bool(benches, true, "Run benches? Does not run GMs-as-benches.");
DEFINE_bool(tests, true, "Run tests?");
DECLARE_bool(verbose);
@ -130,34 +127,6 @@ static void kick_off_gms(const SkTDArray<GMRegistry::Factory>& gms,
#undef START
}
static void kick_off_benches(const SkTDArray<BenchRegistry::Factory>& benches,
const SkTArray<SkString>& configs,
GrGLStandard gpuAPI,
DM::Reporter* reporter,
DM::TaskRunner* tasks) {
#define START(name, type, ...) \
if (lowercase(configs[j]).equals(name)) { \
tasks->add(SkNEW_ARGS(DM::type, (name, reporter, tasks, benches[i], ## __VA_ARGS__))); \
}
for (int i = 0; i < benches.count(); i++) {
for (int j = 0; j < configs.count(); j++) {
START("nonrendering", NonRenderingBenchTask);
START("565", CpuBenchTask, kRGB_565_SkColorType);
START("8888", CpuBenchTask, kN32_SkColorType);
START("gpu", GpuBenchTask, native, gpuAPI, 0);
START("msaa4", GpuBenchTask, native, gpuAPI, 4);
START("msaa16", GpuBenchTask, native, gpuAPI, 16);
START("nvprmsaa4", GpuBenchTask, nvpr, gpuAPI, 4);
START("nvprmsaa16", GpuBenchTask, nvpr, gpuAPI, 16);
START("gpunull", GpuBenchTask, null, gpuAPI, 0);
START("gpudebug", GpuBenchTask, debug, gpuAPI, 0);
START("angle", GpuBenchTask, angle, gpuAPI, 0);
START("mesa", GpuBenchTask, mesa, gpuAPI, 0);
}
}
#undef START
}
static void kick_off_tests(const SkTDArray<TestRegistry::Factory>& tests,
DM::Reporter* reporter,
DM::TaskRunner* tasks) {
@ -269,22 +238,16 @@ int tool_main(int argc, char** argv) {
}
}
SkTDArray<BenchRegistry::Factory> benches;
if (FLAGS_benches) {
append_matching_factories<Benchmark>(BenchRegistry::Head(), &benches);
}
SkTDArray<TestRegistry::Factory> tests;
if (FLAGS_tests) {
append_matching_factories<Test>(TestRegistry::Head(), &tests);
}
SkDebugf("(%d GMs, %d benches) x %d configs, %d tests\n",
gms.count(), benches.count(), configs.count(), tests.count());
SkDebugf("%d GMs x %d configs, %d tests\n",
gms.count(), configs.count(), tests.count());
DM::Reporter reporter;
DM::TaskRunner tasks(FLAGS_threads, FLAGS_gpuThreads);
kick_off_gms(gms, configs, gpuAPI, *expectations, &reporter, &tasks);
kick_off_benches(benches, configs, gpuAPI, &reporter, &tasks);
kick_off_tests(tests, &reporter, &tasks);
kick_off_skps(&reporter, &tasks);
tasks.wait();

View File

@ -1,89 +0,0 @@
#include "DMBenchTask.h"
#include "DMUtil.h"
#include "SkSurface.h"
namespace DM {
static SkString bench_name(const char* name, const char* config) {
SkString result("bench ");
result.appendf("%s_%s", name, config);
return result;
}
NonRenderingBenchTask::NonRenderingBenchTask(const char* config,
Reporter* reporter,
TaskRunner* tasks,
BenchRegistry::Factory factory)
: CpuTask(reporter, tasks)
, fBench(factory(NULL))
, fName(bench_name(fBench->getName(), config)) {}
CpuBenchTask::CpuBenchTask(const char* config,
Reporter* reporter,
TaskRunner* tasks,
BenchRegistry::Factory factory,
SkColorType colorType)
: CpuTask(reporter, tasks)
, fBench(factory(NULL))
, fName(bench_name(fBench->getName(), config))
, fColorType(colorType) {}
GpuBenchTask::GpuBenchTask(const char* config,
Reporter* reporter,
TaskRunner* tasks,
BenchRegistry::Factory factory,
GrContextFactory::GLContextType contextType,
GrGLStandard gpuAPI,
int sampleCount)
: GpuTask(reporter, tasks)
, fBench(factory(NULL))
, fName(bench_name(fBench->getName(), config))
, fContextType(contextType)
, fGpuAPI(gpuAPI)
, fSampleCount(sampleCount) {}
bool NonRenderingBenchTask::shouldSkip() const {
return !fBench->isSuitableFor(Benchmark::kNonRendering_Backend);
}
bool CpuBenchTask::shouldSkip() const {
return !fBench->isSuitableFor(Benchmark::kRaster_Backend);
}
bool GpuBenchTask::shouldSkip() const {
return kGPUDisabled || !fBench->isSuitableFor(Benchmark::kGPU_Backend);
}
static void draw_raster(Benchmark* bench, SkColorType colorType) {
SkBitmap bitmap;
AllocatePixels(colorType, bench->getSize().x(), bench->getSize().y(), &bitmap);
SkCanvas canvas(bitmap);
bench->preDraw();
bench->draw(1, &canvas);
}
void NonRenderingBenchTask::draw() {
draw_raster(fBench.get(), kN32_SkColorType);
}
void CpuBenchTask::draw() {
draw_raster(fBench.get(), fColorType);
}
void GpuBenchTask::draw(GrContextFactory* grFactory) {
SkImageInfo info = SkImageInfo::Make(fBench->getSize().x(),
fBench->getSize().y(),
kN32_SkColorType,
kPremul_SkAlphaType);
SkAutoTUnref<SkSurface> surface(NewGpuSurface(grFactory, fContextType, fGpuAPI, info,
fSampleCount));
if (!surface) {
this->fail("Could not create context for the config and the api.");
return;
}
fBench->preDraw();
fBench->draw(1, surface->getCanvas());
}
} // namespace DM

View File

@ -1,66 +0,0 @@
#ifndef DMBenchTask_DEFINED
#define DMBenchTask_DEFINED
#include "Benchmark.h"
#include "DMReporter.h"
#include "DMTask.h"
#include "DMTaskRunner.h"
#include "SkString.h"
#include "SkTemplates.h"
// Tasks that run an Benchmark once as a check that it doesn't crash.
namespace DM {
class NonRenderingBenchTask : public CpuTask {
public:
NonRenderingBenchTask(const char* config, Reporter*, TaskRunner*, BenchRegistry::Factory);
virtual void draw() SK_OVERRIDE;
virtual bool shouldSkip() const SK_OVERRIDE;
virtual SkString name() const SK_OVERRIDE { return fName; }
private:
SkAutoTDelete<Benchmark> fBench;
const SkString fName;
};
class CpuBenchTask : public CpuTask {
public:
CpuBenchTask(const char* config, Reporter*, TaskRunner*, BenchRegistry::Factory, SkColorType);
virtual void draw() SK_OVERRIDE;
virtual bool shouldSkip() const SK_OVERRIDE;
virtual SkString name() const SK_OVERRIDE { return fName; }
private:
SkAutoTDelete<Benchmark> fBench;
const SkString fName;
const SkColorType fColorType;
};
class GpuBenchTask : public GpuTask {
public:
GpuBenchTask(const char* config,
Reporter*,
TaskRunner*,
BenchRegistry::Factory,
GrContextFactory::GLContextType,
GrGLStandard gpuAPI,
int sampleCount);
virtual void draw(GrContextFactory*) SK_OVERRIDE;
virtual bool shouldSkip() const SK_OVERRIDE;
virtual SkString name() const SK_OVERRIDE { return fName; }
private:
SkAutoTDelete<Benchmark> fBench;
const SkString fName;
const GrContextFactory::GLContextType fContextType;
const GrGLStandard fGpuAPI;
int fSampleCount;
};
} // namespace DM
#endif // DMBenchTask_DEFINED

View File

@ -1,7 +1,6 @@
#ifndef DMUtil_DEFINED
#define DMUtil_DEFINED
#include "Benchmark.h"
#include "SkBitmap.h"
#include "SkString.h"
#include "gm_expectations.h"

View File

@ -7,7 +7,6 @@
'target_name': 'dm',
'type': 'executable',
'include_dirs': [
'../bench',
'../dm',
'../gm',
'../tests',
@ -21,14 +20,12 @@
'../tools',
],
'includes': [
'bench.gypi',
'gmslides.gypi',
'pathops_unittest.gypi',
'tests.gypi',
],
'sources': [
'../dm/DM.cpp',
'../dm/DMBenchTask.cpp',
'../dm/DMCpuGMTask.cpp',
'../dm/DMExpectationsTask.cpp',
'../dm/DMGpuGMTask.cpp',