65a726bb49
These have been renamed SK_MAKE_BITFIELD_OPS and SkAlignTo because nothing seemed particularly GPU/Ganesh specific to them. I moved the latter to SkTypes.h because we have other align code there and former to src/SkUtils.h because I didn't know where else it should go. The primary motivation was removing the GrTypesPriv.h include from src/core/SkBlockAllocator.h. I had attempted some amount of #if SK_SUPPORT_GPU, but that's not as clean here because both our CPU and GPU backends use the SkBlockAllocator (as far as I could tell). This also moves sk_memset* from SkUtils.h to SkOpts.h, because SkOpts.h requires bringing in RasterPipeline, which seemed like overkill. Change-Id: I5163ef5064ad3840a15b7e873930d60e2620bf9d Bug: skia:12584 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/464876 Reviewed-by: Brian Osman <brianosman@google.com>
78 lines
2.6 KiB
C++
78 lines
2.6 KiB
C++
/*
|
|
* Copyright 2013 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#include "bench/Benchmark.h"
|
|
#include "include/private/SkTemplates.h"
|
|
#include "src/core/SkOpts.h"
|
|
|
|
template <typename T>
|
|
class MemsetBench : public Benchmark {
|
|
public:
|
|
explicit MemsetBench(size_t bytes)
|
|
: fN(bytes / sizeof(T))
|
|
, fBuffer(fN)
|
|
, fName(SkStringPrintf("memset%zu_%zu", sizeof(T)*8, bytes)) {}
|
|
|
|
bool isSuitableFor(Backend backend) override { return backend == kNonRendering_Backend; }
|
|
const char* onGetName() override { return fName.c_str(); }
|
|
|
|
void onDraw(int loops, SkCanvas*) override;
|
|
|
|
private:
|
|
int fN;
|
|
SkAutoTMalloc<T> fBuffer;
|
|
SkString fName;
|
|
};
|
|
|
|
template <> void MemsetBench<uint64_t>::onDraw(int loops, SkCanvas*) {
|
|
for (int i = 0; i < 1000*loops; i++) {
|
|
sk_memset64(fBuffer.get(), 0xFACEFACEFACEFACE, fN);
|
|
}
|
|
}
|
|
|
|
template <> void MemsetBench<uint32_t>::onDraw(int loops, SkCanvas*) {
|
|
for (int i = 0; i < 1000*loops; i++) {
|
|
sk_memset32(fBuffer.get(), 0xFACEB004, fN);
|
|
}
|
|
}
|
|
|
|
template <> void MemsetBench<uint16_t>::onDraw(int loops, SkCanvas*) {
|
|
for (int i = 0; i < 1000*loops; i++) {
|
|
sk_memset16(fBuffer.get(), 0x4973, fN);
|
|
}
|
|
}
|
|
|
|
DEF_BENCH(return (new MemsetBench<uint64_t>(16)));
|
|
DEF_BENCH(return (new MemsetBench<uint64_t>(64)));
|
|
DEF_BENCH(return (new MemsetBench<uint64_t>(256)));
|
|
DEF_BENCH(return (new MemsetBench<uint64_t>(512)));
|
|
DEF_BENCH(return (new MemsetBench<uint64_t>(768)));
|
|
DEF_BENCH(return (new MemsetBench<uint64_t>(1024)));
|
|
DEF_BENCH(return (new MemsetBench<uint64_t>(2048)));
|
|
DEF_BENCH(return (new MemsetBench<uint64_t>(4096)));
|
|
DEF_BENCH(return (new MemsetBench<uint64_t>(65536)));
|
|
|
|
DEF_BENCH(return (new MemsetBench<uint32_t>(16)));
|
|
DEF_BENCH(return (new MemsetBench<uint32_t>(64)));
|
|
DEF_BENCH(return (new MemsetBench<uint32_t>(256)));
|
|
DEF_BENCH(return (new MemsetBench<uint32_t>(512)));
|
|
DEF_BENCH(return (new MemsetBench<uint32_t>(768)));
|
|
DEF_BENCH(return (new MemsetBench<uint32_t>(1024)));
|
|
DEF_BENCH(return (new MemsetBench<uint32_t>(2048)));
|
|
DEF_BENCH(return (new MemsetBench<uint32_t>(4096)));
|
|
DEF_BENCH(return (new MemsetBench<uint32_t>(65536)));
|
|
|
|
DEF_BENCH(return (new MemsetBench<uint16_t>(16)));
|
|
DEF_BENCH(return (new MemsetBench<uint16_t>(64)));
|
|
DEF_BENCH(return (new MemsetBench<uint16_t>(256)));
|
|
DEF_BENCH(return (new MemsetBench<uint16_t>(512)));
|
|
DEF_BENCH(return (new MemsetBench<uint16_t>(768)));
|
|
DEF_BENCH(return (new MemsetBench<uint16_t>(1024)));
|
|
DEF_BENCH(return (new MemsetBench<uint16_t>(2048)));
|
|
DEF_BENCH(return (new MemsetBench<uint16_t>(4096)));
|
|
DEF_BENCH(return (new MemsetBench<uint16_t>(65536)));
|