Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
BenchmarkTarget Class Referenceabstract

#include <BenchmarkTarget.h>

Inheritance diagram for BenchmarkTarget:
GaneshBenchmarkTarget RasterBenchmarkTarget NonRenderingBenchmarkTarget

Public Member Functions

virtual ~BenchmarkTarget ()=default
 
virtual Benchmark::Backend getBackend () const =0
 
virtual void setup () const
 
virtual std::tuple< int, bool > autoTuneLoops () const =0
 
virtual void warmUp (int loops) const
 
double time (int loops) const
 
void tearDown () const
 
virtual void dumpStats (skia_private::TArray< SkString > *keys, skia_private::TArray< double > *values) const
 
virtual void printStats () const
 
SkCanvasgetCanvas () const
 
BenchmarkgetBenchmark () const
 
virtual std::map< std::string, std::string > getKeyValuePairs (std::string cpuName, std::string gpuName) const
 
virtual SurfaceManager::CpuOrGpu isCpuOrGpuBound () const
 

Static Public Member Functions

static std::unique_ptr< BenchmarkTargetFromConfig (std::string surfaceConfig, Benchmark *benchmark)
 
static void printGlobalStats ()
 

Protected Member Functions

 BenchmarkTarget (std::unique_ptr< SurfaceManager > surfaceManager, Benchmark *benchmark)
 
virtual SkCanvasonBeforeDraw (SkCanvas *canvas) const
 
virtual void onAfterDraw () const
 
double nowMs () const
 

Protected Attributes

std::unique_ptr< SurfaceManagerfSurfaceManager
 
BenchmarkfBenchmark
 

Detailed Description

Definition at line 21 of file BenchmarkTarget.h.

Constructor & Destructor Documentation

◆ ~BenchmarkTarget()

virtual BenchmarkTarget::~BenchmarkTarget ( )
virtualdefault

◆ BenchmarkTarget()

BenchmarkTarget::BenchmarkTarget ( std::unique_ptr< SurfaceManager surfaceManager,
Benchmark benchmark 
)
inlineprotected

Definition at line 76 of file BenchmarkTarget.h.

77 : fSurfaceManager(std::move(surfaceManager)), fBenchmark(benchmark) {}
std::unique_ptr< SurfaceManager > fSurfaceManager
Benchmark * fBenchmark

Member Function Documentation

◆ autoTuneLoops()

virtual std::tuple< int, bool > BenchmarkTarget::autoTuneLoops ( ) const
pure virtual

◆ dumpStats()

virtual void BenchmarkTarget::dumpStats ( skia_private::TArray< SkString > *  keys,
skia_private::TArray< double > *  values 
) const
inlinevirtual

Reimplemented in GaneshBenchmarkTarget.

Definition at line 56 of file BenchmarkTarget.h.

57 {}

◆ FromConfig()

std::unique_ptr< BenchmarkTarget > BenchmarkTarget::FromConfig ( std::string  surfaceConfig,
Benchmark benchmark 
)
static

Definition at line 173 of file GaneshBenchmarkTarget.cpp.

174 {
175 SurfaceOptions surfaceOptions = {
176 .width = benchmark->getSize().width(),
177 .height = benchmark->getSize().height(),
178 .modifyGrContextOptions = [&](GrContextOptions* grContextOptions) {
179 benchmark->modifyGrContextOptions(grContextOptions);
180 }};
181 std::unique_ptr<SurfaceManager> surfaceManager =
182 SurfaceManager::FromConfig(surfaceConfig, surfaceOptions);
183 if (surfaceManager == nullptr) {
184 SK_ABORT("Unknown --surfaceConfig flag value: %s.", surfaceConfig.c_str());
185 }
186
187 if (surfaceManager->getGaneshContextInfo()->testContext()->fenceSyncSupport()) {
189 "WARNING: GL context for config \"%s\" does not support fence sync. "
190 "Timings might not be accurate.",
191 surfaceConfig.c_str());
192 }
193
194 return std::make_unique<GaneshBenchmarkTarget>(std::move(surfaceManager), benchmark);
195}
#define SK_ABORT(message,...)
Definition: SkAssert.h:70
static std::unique_ptr< SurfaceManager > FromConfig(std::string config, SurfaceOptions surfaceOptions)
void Log(const char *format,...) SK_PRINTF_LIKE(1
Definition: TestRunner.cpp:137

◆ getBackend()

virtual Benchmark::Backend BenchmarkTarget::getBackend ( ) const
pure virtual

◆ getBenchmark()

Benchmark * BenchmarkTarget::getBenchmark ( ) const

Definition at line 43 of file BenchmarkTarget.cpp.

43{ return fBenchmark; }

◆ getCanvas()

SkCanvas * BenchmarkTarget::getCanvas ( ) const

Definition at line 36 of file BenchmarkTarget.cpp.

36 {
37 if (!fSurfaceManager || !fSurfaceManager->getSurface()) {
38 return nullptr; // The NonRenderingBenchmarkTarget has a null SurfaceManager.
39 }
40 return fSurfaceManager->getSurface()->getCanvas();
41}

◆ getKeyValuePairs()

std::map< std::string, std::string > BenchmarkTarget::getKeyValuePairs ( std::string  cpuName,
std::string  gpuName 
) const
virtual

Reimplemented in NonRenderingBenchmarkTarget.

Definition at line 45 of file BenchmarkTarget.cpp.

46 {
48 return fSurfaceManager->getPerfKeyValuePairs(cpuName, gpuName);
49}
#define SkASSERT_RELEASE(cond)
Definition: SkAssert.h:100

◆ isCpuOrGpuBound()

SurfaceManager::CpuOrGpu BenchmarkTarget::isCpuOrGpuBound ( ) const
virtual

Reimplemented in NonRenderingBenchmarkTarget.

Definition at line 51 of file BenchmarkTarget.cpp.

51 {
53 return fSurfaceManager->isCpuOrGpuBound();
54}

◆ nowMs()

double BenchmarkTarget::nowMs ( ) const
protected

Definition at line 56 of file BenchmarkTarget.cpp.

56{ return SkTime::GetNSecs() * 1e-6; }
double GetNSecs()
Definition: SkTime.cpp:17

◆ onAfterDraw()

virtual void BenchmarkTarget::onAfterDraw ( ) const
inlineprotectedvirtual

Reimplemented in GaneshBenchmarkTarget.

Definition at line 84 of file BenchmarkTarget.h.

84{}

◆ onBeforeDraw()

virtual SkCanvas * BenchmarkTarget::onBeforeDraw ( SkCanvas canvas) const
inlineprotectedvirtual

Definition at line 81 of file BenchmarkTarget.h.

81{ return canvas; }

◆ printGlobalStats()

void BenchmarkTarget::printGlobalStats ( )
static

Definition at line 53 of file GaneshBenchmarkTarget.cpp.

53 {
54 if (FLAGS_dmsaaStatsDump) {
55 TestRunner::Log("<<Total Combined DMSAA Stats>>");
56 combinedDMSAAStats.dump();
57 }
58}
GrRecordingContextPriv::DMSAAStats combinedDMSAAStats

◆ printStats()

virtual void BenchmarkTarget::printStats ( ) const
inlinevirtual

Reimplemented in GaneshBenchmarkTarget.

Definition at line 60 of file BenchmarkTarget.h.

60{}

◆ setup()

void BenchmarkTarget::setup ( ) const
virtual

Reimplemented in GaneshBenchmarkTarget.

Definition at line 15 of file BenchmarkTarget.cpp.

SkCanvas * getCanvas() const
void perCanvasPreDraw(SkCanvas *)
Definition: Benchmark.cpp:34

◆ tearDown()

void BenchmarkTarget::tearDown ( ) const

Definition at line 34 of file BenchmarkTarget.cpp.

void perCanvasPostDraw(SkCanvas *)
Definition: Benchmark.cpp:46

◆ time()

double BenchmarkTarget::time ( int  loops) const

Definition at line 17 of file BenchmarkTarget.cpp.

17 {
18 SkCanvas* canvas = getCanvas();
19 if (canvas) {
20 canvas->clear(SK_ColorWHITE);
21 }
22 fBenchmark->preDraw(canvas);
23 double start = nowMs();
24 canvas = onBeforeDraw(canvas);
25
26 fBenchmark->draw(loops, canvas);
27
29 double elapsed = nowMs() - start;
30 fBenchmark->postDraw(canvas);
31 return elapsed;
32}
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
double nowMs() const
virtual void onAfterDraw() const
virtual SkCanvas * onBeforeDraw(SkCanvas *canvas) const
void draw(int loops, SkCanvas *)
Definition: Benchmark.cpp:50
void postDraw(SkCanvas *)
Definition: Benchmark.cpp:42
void preDraw(SkCanvas *)
Definition: Benchmark.cpp:38
void clear(SkColor color)
Definition: SkCanvas.h:1199

◆ warmUp()

virtual void BenchmarkTarget::warmUp ( int  loops) const
inlinevirtual

Reimplemented in GaneshBenchmarkTarget.

Definition at line 45 of file BenchmarkTarget.h.

45{}

Member Data Documentation

◆ fBenchmark

Benchmark* BenchmarkTarget::fBenchmark
protected

Definition at line 89 of file BenchmarkTarget.h.

◆ fSurfaceManager

std::unique_ptr<SurfaceManager> BenchmarkTarget::fSurfaceManager
protected

Definition at line 88 of file BenchmarkTarget.h.


The documentation for this class was generated from the following files: