Flutter Engine
The Flutter Engine
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
ComputeChecksumBench Class Reference
Inheritance diagram for ComputeChecksumBench:
Benchmark SkRefCnt SkRefCntBase

Public Member Functions

 ComputeChecksumBench (ChecksumType type, size_t blockSize)
 
bool isSuitableFor (Backend backend) override
 
const char * onGetName () override
 
void onPreDraw (SkCanvas *) override
 
void onPostDraw (SkCanvas *) override
 
void onDraw (int loops, SkCanvas *) override
 
- Public Member Functions inherited from Benchmark
 Benchmark ()
 
const char * getName ()
 
const char * getUniqueName ()
 
SkISize getSize ()
 
virtual bool isSuitableFor (Backend backend)
 
virtual void modifyGrContextOptions (GrContextOptions *)
 
virtual bool shouldLoop () const
 
void delayedSetup ()
 
void perCanvasPreDraw (SkCanvas *)
 
void perCanvasPostDraw (SkCanvas *)
 
void preDraw (SkCanvas *)
 
void postDraw (SkCanvas *)
 
void draw (int loops, SkCanvas *)
 
virtual void getGpuStats (SkCanvas *, skia_private::TArray< SkString > *keys, skia_private::TArray< double > *values)
 
virtual bool getDMSAAStats (GrRecordingContext *)
 
int getUnits () const
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Public Attributes

ChecksumType fType
 
size_t fBlockSize
 
SkString fName
 
std::unique_ptr< uint8_t[]> fData
 

Static Public Attributes

static constexpr size_t kBufferSize = 64 * 1024
 

Additional Inherited Members

- Public Types inherited from Benchmark
enum class  Backend {
  kNonRendering , kRaster , kGanesh , kGraphite ,
  kPDF , kHWUI
}
 
- Protected Member Functions inherited from Benchmark
void setUnits (int units)
 
virtual void setupPaint (SkPaint *paint)
 
virtual const char * onGetName ()=0
 
virtual const char * onGetUniqueName ()
 
virtual void onDelayedSetup ()
 
virtual void onPerCanvasPreDraw (SkCanvas *)
 
virtual void onPerCanvasPostDraw (SkCanvas *)
 
virtual void onPreDraw (SkCanvas *)
 
virtual void onPostDraw (SkCanvas *)
 
virtual void onDraw (int loops, SkCanvas *)=0
 
virtual SkISize onGetSize ()
 

Detailed Description

Definition at line 22 of file ChecksumBench.cpp.

Constructor & Destructor Documentation

◆ ComputeChecksumBench()

ComputeChecksumBench::ComputeChecksumBench ( ChecksumType  type,
size_t  blockSize 
)
inline

Definition at line 33 of file ChecksumBench.cpp.

33 : fType(type), fBlockSize(blockSize) {
34 SkASSERT(blockSize <= kBufferSize);
35
36 switch (fType) {
37 case kMD5_ChecksumType: fName = "compute_md5"; break;
38 case kWyhash_ChecksumType: fName = "compute_wyhash"; break;
39 }
40 fName.appendf("_%d", static_cast<int>(fBlockSize));
41 }
@ kMD5_ChecksumType
@ kWyhash_ChecksumType
#define SkASSERT(cond)
Definition: SkAssert.h:116
GLenum type
static constexpr size_t kBufferSize
void void void appendf(const char format[],...) SK_PRINTF_LIKE(2
Definition: SkString.cpp:550

Member Function Documentation

◆ isSuitableFor()

bool ComputeChecksumBench::isSuitableFor ( Backend  backend)
inlineoverridevirtual

Reimplemented from Benchmark.

Definition at line 43 of file ChecksumBench.cpp.

const char * backend

◆ onDraw()

void ComputeChecksumBench::onDraw ( int  loops,
SkCanvas  
)
inlineoverridevirtual

Implements Benchmark.

Definition at line 59 of file ChecksumBench.cpp.

59 {
60 volatile uint32_t result = 0;
61 const size_t blockCount = kBufferSize / fBlockSize;
62 const uint8_t* bufEnd = fData.get() + (blockCount * fBlockSize);
63 for (int i = 0; i < loops; i++) {
64 for (const uint8_t* buf = fData.get(); buf < bufEnd; buf += fBlockSize) {
65 switch (fType) {
66 case kMD5_ChecksumType: {
67 SkMD5 md5;
68 md5.write(buf, fBlockSize);
69 (void)md5.finish();
70 break;
71 }
74 break;
75 }
76 }
77 }
79 }
static SkMD5::Digest md5(const SkBitmap &bm)
Definition: CodecTest.cpp:77
void sk_ignore_unused_variable(const T &)
Definition: SkTemplates.h:37
std::unique_ptr< uint8_t[]> fData
Definition: SkMD5.h:19
GAsyncResult * result
uint32_t Hash32(const void *data, size_t bytes, uint32_t seed)
Definition: SkChecksum.cpp:113

◆ onGetName()

const char * ComputeChecksumBench::onGetName ( )
inlineoverridevirtual

Implements Benchmark.

Definition at line 44 of file ChecksumBench.cpp.

44{ return fName.c_str(); }
const char * c_str() const
Definition: SkString.h:133

◆ onPostDraw()

void ComputeChecksumBench::onPostDraw ( SkCanvas )
inlineoverridevirtual

Reimplemented from Benchmark.

Definition at line 55 of file ChecksumBench.cpp.

55 {
56 fData.reset();
57 }

◆ onPreDraw()

void ComputeChecksumBench::onPreDraw ( SkCanvas )
inlineoverridevirtual

Reimplemented from Benchmark.

Definition at line 46 of file ChecksumBench.cpp.

46 {
47 fData.reset(new uint8_t[kBufferSize]);
48
49 SkRandom rand;
50 for (size_t i = 0; i < kBufferSize; ++i) {
51 fData[i] = rand.nextBits(8);
52 }
53 }
uint32_t nextBits(unsigned bitCount)
Definition: SkRandom.h:72

Member Data Documentation

◆ fBlockSize

size_t ComputeChecksumBench::fBlockSize

Definition at line 29 of file ChecksumBench.cpp.

◆ fData

std::unique_ptr<uint8_t[]> ComputeChecksumBench::fData

Definition at line 31 of file ChecksumBench.cpp.

◆ fName

SkString ComputeChecksumBench::fName

Definition at line 30 of file ChecksumBench.cpp.

◆ fType

ChecksumType ComputeChecksumBench::fType

Definition at line 28 of file ChecksumBench.cpp.

◆ kBufferSize

constexpr size_t ComputeChecksumBench::kBufferSize = 64 * 1024
staticconstexpr

Definition at line 26 of file ChecksumBench.cpp.


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