Flutter Engine
The Flutter Engine
CubicMapBench.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2018 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#include "bench/Benchmark.h"
10
11class CubicMapBench : public Benchmark {
12public:
13 CubicMapBench(SkPoint p1, SkPoint p2) : fCMap(p1, p2) {
14 fName.printf("cubicmap_%g_%g_%g_%g", p1.fX, p1.fY, p2.fX, p2.fY);
15 }
16
17 bool isSuitableFor(Backend backend) override {
19 }
20
21 const char* onGetName() override {
22 return fName.c_str();
23 }
24
25 void onDraw(int loops, SkCanvas*) override {
26 for (int outer = 0; outer < 100; ++outer) {
27 for (int i = 0; i < loops; ++i) {
28 for (SkScalar x = 0; x <= 1; x += 1.0f / 512) {
29 fCMap.computeYFromX(x);
30 }
31 }
32 }
33 }
34
35private:
36 SkCubicMap fCMap;
37 SkString fName;
38
39 using INHERITED = Benchmark;
40};
41
42DEF_BENCH( return new CubicMapBench({1, 0}, {0,0}); )
43DEF_BENCH( return new CubicMapBench({1, 0}, {0,1}); )
44DEF_BENCH( return new CubicMapBench({1, 0}, {1,0}); )
45DEF_BENCH( return new CubicMapBench({1, 0}, {1,1}); )
46
47DEF_BENCH( return new CubicMapBench({0, 1}, {0,0}); )
48DEF_BENCH( return new CubicMapBench({0, 1}, {0,1}); )
49DEF_BENCH( return new CubicMapBench({0, 1}, {1,0}); )
50DEF_BENCH( return new CubicMapBench({0, 1}, {1,1}); )
51
52DEF_BENCH( return new CubicMapBench({0, 0}, {1,1}); )
53DEF_BENCH( return new CubicMapBench({1, 1}, {0,0}); )
#define DEF_BENCH(code)
Definition: Benchmark.h:20
const char * backend
CubicMapBench(SkPoint p1, SkPoint p2)
void onDraw(int loops, SkCanvas *) override
bool isSuitableFor(Backend backend) override
const char * onGetName() override
float computeYFromX(float x) const
Definition: SkCubicMap.cpp:61
void printf(const char format[],...) SK_PRINTF_LIKE(2
Definition: SkString.cpp:534
const char * c_str() const
Definition: SkString.h:133
float SkScalar
Definition: extension.cpp:12
double x
float fX
x-axis value
Definition: SkPoint_impl.h:164
float fY
y-axis value
Definition: SkPoint_impl.h:165