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

Public Member Functions

 RasterBenchmarkTarget (std::unique_ptr< SurfaceManager > surfaceManager, Benchmark *benchmark)
 
Benchmark::Backend getBackend () const override
 
std::tuple< int, bool > autoTuneLoops () 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 27 of file RasterBenchmarkTarget.cpp.

Constructor & Destructor Documentation

◆ RasterBenchmarkTarget()

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

Definition at line 29 of file RasterBenchmarkTarget.cpp.

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

Member Function Documentation

◆ autoTuneLoops()

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

Implements BenchmarkTarget.

Definition at line 36 of file RasterBenchmarkTarget.cpp.

36 {
37 // Estimate timer overhead. Based on:
38 // https://skia.googlesource.com/skia/+/a063eaeaf1e09e4d6f42e0f44a5723622a46d21c/bench/nanobench.cpp#402.
39 double overhead = 0;
40 for (int i = 0; i < FLAGS_overheadLoops; i++) {
41 double start = nowMs();
42 overhead += nowMs() - start;
43 }
44 overhead /= FLAGS_overheadLoops;
45
46 // First figure out approximately how many loops of bench it takes to make overhead
47 // negligible.
48 double bench_plus_overhead = 0.0;
49 int round = 0;
50 while (bench_plus_overhead < overhead) {
51 if (round++ == FLAGS_maxCalibrationAttempts) {
52 TestRunner::Log("Warning: Cannot estimate loops for %s (%s vs. %s); skipping.",
54 humanize(bench_plus_overhead).c_str(),
55 humanize(overhead).c_str());
56 return std::make_tuple(0, false);
57 }
58 bench_plus_overhead = time(1);
59 }
60
61 // Later we'll just start and stop the timer once but loop N times.
62 // We'll pick N to make timer overhead negligible:
63 //
64 // overhead
65 // ------------------------- < FLAGS_overheadGoal
66 // overhead + N * Bench Time
67 //
68 // where bench_plus_overhead ~=~ overhead + Bench Time.
69 //
70 // Doing some math, we get:
71 //
72 // (overhead / FLAGS_overheadGoal) - overhead
73 // ------------------------------------------ < N
74 // bench_plus_overhead - overhead)
75 //
76 // Luckily, this also works well in practice. :)
77 const double numer = overhead / FLAGS_overheadGoal - overhead;
78 const double denom = bench_plus_overhead - overhead;
79 int loops = (int)ceil(numer / denom);
80
81 return std::make_tuple(loops, true);
82 }
static void round(SkPoint *p)
SkString humanize(double ms)
Benchmark * fBenchmark
double nowMs() const
double time(int loops) const
const char * getUniqueName()
Definition: Benchmark.cpp:22
void Log(const char *format,...) SK_PRINTF_LIKE(1
Definition: TestRunner.cpp:137
SIN Vec< N, float > ceil(const Vec< N, float > &x)
Definition: SkVx.h:702

◆ getBackend()

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

Implements BenchmarkTarget.

Reimplemented in NonRenderingBenchmarkTarget.

Definition at line 32 of file RasterBenchmarkTarget.cpp.


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