17struct alignas(GrMemoryPool::kAlignment) Aligned {
20static_assert(
sizeof(Aligned) == 32);
25struct alignas(2) Unaligned {
28static_assert(
sizeof(Unaligned) == 30);
44 static const int kMaxObjects = 4 * (1 << 10);
46 for (
int i = 0;
i < loops; ++
i) {
48 for (
int j = 0; j < kMaxObjects; ++j) {
49 objs[j] =
pool ? (
T*)
pool->allocate(
sizeof(
T)) :
new T;
52 for (
int j = kMaxObjects - 1; j >= 0; --j) {
54 pool->release(objs[j]);
68 static const int kMaxObjects = 4 * (1 << 10);
70 for (
int i = 0;
i < loops; ++
i) {
72 for (
int j = 0; j < kMaxObjects; ++j) {
73 objs[j] =
pool ? (
T*)
pool->allocate(
sizeof(
T)) :
new T;
76 for (
int j = 0; j < kMaxObjects; ++j) {
78 pool->release(objs[j]);
92 static const int kMaxObjects = 4 * (1 << 10);
94 for (
int i = 0;
i < loops; ++
i) {
96 for (
int j = 0; j < kMaxObjects; ++j) {
98 objs[j] = (
T*)
pool->allocate(
sizeof(
T));
99 pool->release(objs[j]);
113 static const int kMaxObjects = 4 * (1 << 10);
114 T* objs[kMaxObjects];
115 for (
int i = 0;
i < kMaxObjects; ++
i) {
119 auto del = [&](
int j) {
122 pool->release(objs[j]);
130 for (
int i = 0;
i < loops; ++
i) {
133 for (
int j = 0; j < 2 * kMaxObjects; ++j) {
139 objs[k] =
pool ? (
T*)
pool->allocate(
sizeof(
T)) :
new T;
144 for (
int j = 0; j < kMaxObjects; ++j) {
172 std::unique_ptr<GrMemoryPool>
pool;
static void run_queue(GrMemoryPool *pool, int loops)
static void run_pushpop(GrMemoryPool *pool, int loops)
static const int kLargePool
static const int kSmallPool
static void run_stack(GrMemoryPool *pool, int loops)
static void run_random(GrMemoryPool *pool, int loops)
static constexpr size_t SkAlignTo(size_t x, size_t alignment)
const char * onGetName() override
void onDraw(int loops, SkCanvas *) override
GrMemoryPoolBench(const char *name, RunBenchProc proc, int poolSize)
bool isSuitableFor(Backend backend) override
static constexpr size_t kAlignment
static std::unique_ptr< GrMemoryPool > Make(size_t preallocSize, size_t minAllocSize)
static constexpr size_t kMinAllocationSize
uint32_t nextRangeU(uint32_t min, uint32_t max)
void printf(const char format[],...) SK_PRINTF_LIKE(2
const char * c_str() const
DEF_SWITCHES_START aot vmservice shared library name