skia2/bench/ChecksumBench.cpp
robertphillips@google.com 433ce5e686 Made more benchs non-rendering
http://codereview.appspot.com/6498132/



git-svn-id: http://skia.googlecode.com/svn/trunk@5562 2bbb7eff-a529-9590-31e7-b0007b416f81
2012-09-17 10:49:30 +00:00

49 lines
1.1 KiB
C++

/*
* Copyright 2012 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "SkBenchmark.h"
#include "SkCanvas.h"
#include "SkChecksum.h"
#include "SkRandom.h"
class ComputeChecksumBench : public SkBenchmark {
enum {
U32COUNT = 256,
SIZE = U32COUNT * 4,
N = SkBENCHLOOP(100000),
};
uint32_t fData[U32COUNT];
public:
ComputeChecksumBench(void* param) : INHERITED(param) {
SkRandom rand;
for (int i = 0; i < U32COUNT; ++i) {
fData[i] = rand.nextU();
}
fIsRendering = false;
}
protected:
virtual const char* onGetName() {
return "compute_checksum";
}
virtual void onDraw(SkCanvas* canvas) {
for (int i = 0; i < N; i++) {
volatile uint32_t result = SkChecksum::Compute(fData, sizeof(fData));
}
}
private:
typedef SkBenchmark INHERITED;
};
///////////////////////////////////////////////////////////////////////////////
static SkBenchmark* Fact0(void* p) { return new ComputeChecksumBench(p); }
static BenchRegistry gReg0(Fact0);