Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
GaneshBenchmarkTarget Class Reference
Inheritance diagram for GaneshBenchmarkTarget:
BenchmarkTarget

Public Member Functions

 GaneshBenchmarkTarget (std::unique_ptr< SurfaceManager > surfaceManager, Benchmark *benchmark)
 
 ~GaneshBenchmarkTarget () override
 
Benchmark::Backend getBackend () const override
 
void setup () const override
 
void onAfterDraw () const override
 
std::tuple< int, bool > autoTuneLoops () const override
 
void warmUp (int loops) const override
 
void dumpStats (skia_private::TArray< SkString > *keys, skia_private::TArray< double > *values) const override
 
void printStats () const override
 
- Public Member Functions inherited from BenchmarkTarget
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
 

Additional Inherited Members

- Static Public Member Functions inherited from BenchmarkTarget
static std::unique_ptr< BenchmarkTargetFromConfig (std::string surfaceConfig, Benchmark *benchmark)
 
static void printGlobalStats ()
 
- Protected Member Functions inherited from BenchmarkTarget
 BenchmarkTarget (std::unique_ptr< SurfaceManager > surfaceManager, Benchmark *benchmark)
 
virtual SkCanvasonBeforeDraw (SkCanvas *canvas) const
 
virtual void onAfterDraw () const
 
double nowMs () const
 
- Protected Attributes inherited from BenchmarkTarget
std::unique_ptr< SurfaceManagerfSurfaceManager
 
BenchmarkfBenchmark
 

Detailed Description

Definition at line 62 of file GaneshBenchmarkTarget.cpp.

Constructor & Destructor Documentation

◆ GaneshBenchmarkTarget()

GaneshBenchmarkTarget::GaneshBenchmarkTarget ( std::unique_ptr< SurfaceManager surfaceManager,
Benchmark benchmark 
)
inline

Definition at line 64 of file GaneshBenchmarkTarget.cpp.

65 : BenchmarkTarget(std::move(surfaceManager), benchmark) {}
BenchmarkTarget(std::unique_ptr< SurfaceManager > surfaceManager, Benchmark *benchmark)

◆ ~GaneshBenchmarkTarget()

GaneshBenchmarkTarget::~GaneshBenchmarkTarget ( )
inlineoverride

Definition at line 67 of file GaneshBenchmarkTarget.cpp.

67 {
68 // For Vulkan we need to release all our refs to the GrContext before destroy the vulkan
69 // context which happens at the end of this destructor. Thus we need to release the surface
70 // here which holds a ref to the GrContext.
71 fSurfaceManager->getSurface().reset();
72 }
std::unique_ptr< SurfaceManager > fSurfaceManager

Member Function Documentation

◆ autoTuneLoops()

std::tuple< int, bool > GaneshBenchmarkTarget::autoTuneLoops ( ) const
inlineoverridevirtual

Implements BenchmarkTarget.

Definition at line 95 of file GaneshBenchmarkTarget.cpp.

95 {
96 int maxFrameLag = computeMaxFrameLag();
97
98 // First, figure out how many loops it'll take to get a frame up to FLAGS_gpuMs.
99 int loops = 1;
100 double elapsed = 0;
101 do {
102 if (1 << 30 == loops) {
103 // We're about to wrap. Something's wrong with the bench.
104 loops = 0;
105 break;
106 }
107 loops *= 2;
108 // If the GPU lets frames lag at all, we need to make sure we're timing
109 // _this_ round, not still timing last round.
110 for (int i = 0; i < maxFrameLag; i++) {
111 elapsed = time(loops);
112 }
113 } while (elapsed < FLAGS_gpuMs);
114
115 // We've overshot at least a little. Scale back linearly.
116 loops = (int)ceil(loops * FLAGS_gpuMs / elapsed);
117
118 // Make sure we're not still timing our calibration.
119 fSurfaceManager->getGaneshContextInfo()->testContext()->finish();
120
121 return std::make_tuple(loops, true);
122 }
double time(int loops) const
SIN Vec< N, float > ceil(const Vec< N, float > &x)
Definition: SkVx.h:702

◆ dumpStats()

void GaneshBenchmarkTarget::dumpStats ( skia_private::TArray< SkString > *  keys,
skia_private::TArray< double > *  values 
) const
inlineoverridevirtual

Reimplemented from BenchmarkTarget.

Definition at line 135 of file GaneshBenchmarkTarget.cpp.

136 {
137 if (FLAGS_gpuStatsDump) {
138 // TODO cache stats
140 }
141 if (FLAGS_dmsaaStatsDump && fBenchmark->getDMSAAStats(getCanvas()->recordingContext())) {
142 const auto& dmsaaStats = getCanvas()->recordingContext()->priv().dmsaaStats();
143 dmsaaStats.dumpKeyValuePairs(keys, values);
144 dmsaaStats.dump();
145 combinedDMSAAStats.merge(dmsaaStats);
146 }
147 }
GrRecordingContextPriv::DMSAAStats combinedDMSAAStats
Benchmark * fBenchmark
SkCanvas * getCanvas() const
virtual void getGpuStats(SkCanvas *, skia_private::TArray< SkString > *keys, skia_private::TArray< double > *values)
Definition: Benchmark.h:84
virtual bool getDMSAAStats(GrRecordingContext *)
Definition: Benchmark.h:89
GrRecordingContextPriv priv()
virtual GrRecordingContext * recordingContext() const
Definition: SkCanvas.cpp:1637

◆ getBackend()

Benchmark::Backend GaneshBenchmarkTarget::getBackend ( ) const
inlineoverridevirtual

Implements BenchmarkTarget.

Definition at line 74 of file GaneshBenchmarkTarget.cpp.

◆ onAfterDraw()

void GaneshBenchmarkTarget::onAfterDraw ( ) const
inlineoverridevirtual

Reimplemented from BenchmarkTarget.

Definition at line 86 of file GaneshBenchmarkTarget.cpp.

86 {
87 if (fSurfaceManager->getGaneshContextInfo()->testContext()) {
88 fSurfaceManager->getGaneshContextInfo()->testContext()->flushAndWaitOnSync(
89 fSurfaceManager->getGaneshContextInfo()->directContext());
90 }
91 }

◆ printStats()

void GaneshBenchmarkTarget::printStats ( ) const
inlineoverridevirtual

Reimplemented from BenchmarkTarget.

Definition at line 149 of file GaneshBenchmarkTarget.cpp.

149 {
150 if (FLAGS_gpuStats) {
151 auto context = fSurfaceManager->getGaneshContextInfo()->directContext();
152
153 context->priv().printCacheStats();
154 context->priv().printGpuStats();
155 context->priv().printContextStats();
156 }
157 }

◆ setup()

void GaneshBenchmarkTarget::setup ( ) const
inlineoverridevirtual

Reimplemented from BenchmarkTarget.

Definition at line 77 of file GaneshBenchmarkTarget.cpp.

77 {
78 fSurfaceManager->getGaneshContextInfo()->testContext()->makeCurrent();
79 // Make sure we're done with whatever came before.
80 fSurfaceManager->getGaneshContextInfo()->testContext()->finish();
81
83 }
virtual void setup() const

◆ warmUp()

void GaneshBenchmarkTarget::warmUp ( int  loops) const
inlineoverridevirtual

Reimplemented from BenchmarkTarget.

Definition at line 126 of file GaneshBenchmarkTarget.cpp.

126 {
127 // Pretty much the same deal as the calibration: do some warmup to make
128 // sure we're timing steady-state pipelined frames.
129 int maxFrameLag = computeMaxFrameLag();
130 for (int i = 0; i < maxFrameLag; i++) {
131 time(loops);
132 }
133 }

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