Merge "Switch hwui to google-benchmark" into nyc-dev
This commit is contained in:
@@ -304,13 +304,13 @@ LOCAL_MODULE_STEM_64 := hwuimicro64
|
||||
LOCAL_CFLAGS := \
|
||||
$(hwui_cflags) \
|
||||
-DHWUI_NULL_GPU
|
||||
LOCAL_C_INCLUDES += bionic/benchmarks/
|
||||
|
||||
LOCAL_WHOLE_STATIC_LIBRARIES := libhwui_static_null_gpu
|
||||
LOCAL_STATIC_LIBRARIES := libbenchmark libbase
|
||||
LOCAL_STATIC_LIBRARIES := libgoogle-benchmark
|
||||
|
||||
LOCAL_SRC_FILES += \
|
||||
$(hwui_test_common_src_files) \
|
||||
tests/microbench/main.cpp \
|
||||
tests/microbench/DisplayListCanvasBench.cpp \
|
||||
tests/microbench/LinearAllocatorBench.cpp \
|
||||
tests/microbench/PathParserBench.cpp \
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <benchmark/Benchmark.h>
|
||||
#include <benchmark/benchmark.h>
|
||||
|
||||
#include "DisplayList.h"
|
||||
#if HWUI_NEW_OPS
|
||||
@@ -23,7 +23,6 @@
|
||||
#include "DisplayListCanvas.h"
|
||||
#endif
|
||||
#include "tests/common/TestUtils.h"
|
||||
#include "tests/microbench/MicroBench.h"
|
||||
|
||||
using namespace android;
|
||||
using namespace android::uirenderer;
|
||||
@@ -34,74 +33,64 @@ typedef RecordingCanvas TestCanvas;
|
||||
typedef DisplayListCanvas TestCanvas;
|
||||
#endif
|
||||
|
||||
BENCHMARK_NO_ARG(BM_DisplayList_alloc);
|
||||
void BM_DisplayList_alloc::Run(int iters) {
|
||||
StartBenchmarkTiming();
|
||||
for (int i = 0; i < iters; ++i) {
|
||||
void BM_DisplayList_alloc(benchmark::State& benchState) {
|
||||
while (benchState.KeepRunning()) {
|
||||
auto displayList = new DisplayList();
|
||||
MicroBench::DoNotOptimize(displayList);
|
||||
benchmark::DoNotOptimize(displayList);
|
||||
delete displayList;
|
||||
}
|
||||
StopBenchmarkTiming();
|
||||
}
|
||||
BENCHMARK(BM_DisplayList_alloc);
|
||||
|
||||
BENCHMARK_NO_ARG(BM_DisplayList_alloc_theoretical);
|
||||
void BM_DisplayList_alloc_theoretical::Run(int iters) {
|
||||
StartBenchmarkTiming();
|
||||
for (int i = 0; i < iters; ++i) {
|
||||
void BM_DisplayList_alloc_theoretical(benchmark::State& benchState) {
|
||||
while (benchState.KeepRunning()) {
|
||||
auto displayList = new char[sizeof(DisplayList)];
|
||||
MicroBench::DoNotOptimize(displayList);
|
||||
benchmark::DoNotOptimize(displayList);
|
||||
delete[] displayList;
|
||||
}
|
||||
StopBenchmarkTiming();
|
||||
}
|
||||
BENCHMARK(BM_DisplayList_alloc_theoretical);
|
||||
|
||||
BENCHMARK_NO_ARG(BM_DisplayListCanvas_record_empty);
|
||||
void BM_DisplayListCanvas_record_empty::Run(int iters) {
|
||||
void BM_DisplayListCanvas_record_empty(benchmark::State& benchState) {
|
||||
TestCanvas canvas(100, 100);
|
||||
delete canvas.finishRecording();
|
||||
|
||||
StartBenchmarkTiming();
|
||||
for (int i = 0; i < iters; ++i) {
|
||||
while (benchState.KeepRunning()) {
|
||||
canvas.resetRecording(100, 100);
|
||||
MicroBench::DoNotOptimize(&canvas);
|
||||
benchmark::DoNotOptimize(&canvas);
|
||||
delete canvas.finishRecording();
|
||||
}
|
||||
StopBenchmarkTiming();
|
||||
}
|
||||
BENCHMARK(BM_DisplayListCanvas_record_empty);
|
||||
|
||||
BENCHMARK_NO_ARG(BM_DisplayListCanvas_record_saverestore);
|
||||
void BM_DisplayListCanvas_record_saverestore::Run(int iters) {
|
||||
void BM_DisplayListCanvas_record_saverestore(benchmark::State& benchState) {
|
||||
TestCanvas canvas(100, 100);
|
||||
delete canvas.finishRecording();
|
||||
|
||||
StartBenchmarkTiming();
|
||||
for (int i = 0; i < iters; ++i) {
|
||||
while (benchState.KeepRunning()) {
|
||||
canvas.resetRecording(100, 100);
|
||||
canvas.save(SaveFlags::MatrixClip);
|
||||
canvas.save(SaveFlags::MatrixClip);
|
||||
MicroBench::DoNotOptimize(&canvas);
|
||||
benchmark::DoNotOptimize(&canvas);
|
||||
canvas.restore();
|
||||
canvas.restore();
|
||||
delete canvas.finishRecording();
|
||||
}
|
||||
StopBenchmarkTiming();
|
||||
}
|
||||
BENCHMARK(BM_DisplayListCanvas_record_saverestore);
|
||||
|
||||
BENCHMARK_NO_ARG(BM_DisplayListCanvas_record_translate);
|
||||
void BM_DisplayListCanvas_record_translate::Run(int iters) {
|
||||
void BM_DisplayListCanvas_record_translate(benchmark::State& benchState) {
|
||||
TestCanvas canvas(100, 100);
|
||||
delete canvas.finishRecording();
|
||||
|
||||
StartBenchmarkTiming();
|
||||
for (int i = 0; i < iters; ++i) {
|
||||
while (benchState.KeepRunning()) {
|
||||
canvas.resetRecording(100, 100);
|
||||
canvas.scale(10, 10);
|
||||
MicroBench::DoNotOptimize(&canvas);
|
||||
benchmark::DoNotOptimize(&canvas);
|
||||
delete canvas.finishRecording();
|
||||
}
|
||||
StopBenchmarkTiming();
|
||||
}
|
||||
BENCHMARK(BM_DisplayListCanvas_record_translate);
|
||||
|
||||
/**
|
||||
* Simulate a simple view drawing a background, overlapped by an image.
|
||||
@@ -109,16 +98,14 @@ void BM_DisplayListCanvas_record_translate::Run(int iters) {
|
||||
* Note that the recording commands are intentionally not perfectly efficient, as the
|
||||
* View system frequently produces unneeded save/restores.
|
||||
*/
|
||||
BENCHMARK_NO_ARG(BM_DisplayListCanvas_record_simpleBitmapView);
|
||||
void BM_DisplayListCanvas_record_simpleBitmapView::Run(int iters) {
|
||||
void BM_DisplayListCanvas_record_simpleBitmapView(benchmark::State& benchState) {
|
||||
TestCanvas canvas(100, 100);
|
||||
delete canvas.finishRecording();
|
||||
|
||||
SkPaint rectPaint;
|
||||
SkBitmap iconBitmap = TestUtils::createSkBitmap(80, 80);
|
||||
|
||||
StartBenchmarkTiming();
|
||||
for (int i = 0; i < iters; ++i) {
|
||||
while (benchState.KeepRunning()) {
|
||||
canvas.resetRecording(100, 100);
|
||||
{
|
||||
canvas.save(SaveFlags::MatrixClip);
|
||||
@@ -131,11 +118,11 @@ void BM_DisplayListCanvas_record_simpleBitmapView::Run(int iters) {
|
||||
canvas.drawBitmap(iconBitmap, 0, 0, nullptr);
|
||||
canvas.restore();
|
||||
}
|
||||
MicroBench::DoNotOptimize(&canvas);
|
||||
benchmark::DoNotOptimize(&canvas);
|
||||
delete canvas.finishRecording();
|
||||
}
|
||||
StopBenchmarkTiming();
|
||||
}
|
||||
BENCHMARK(BM_DisplayListCanvas_record_simpleBitmapView);
|
||||
|
||||
class NullClient: public CanvasStateClient {
|
||||
void onViewportInitialized() override {}
|
||||
@@ -143,48 +130,42 @@ class NullClient: public CanvasStateClient {
|
||||
GLuint getTargetFbo() const override { return 0; }
|
||||
};
|
||||
|
||||
BENCHMARK_NO_ARG(BM_CanvasState_saverestore);
|
||||
void BM_CanvasState_saverestore::Run(int iters) {
|
||||
void BM_CanvasState_saverestore(benchmark::State& benchState) {
|
||||
NullClient client;
|
||||
CanvasState state(client);
|
||||
state.initializeSaveStack(100, 100, 0, 0, 100, 100, Vector3());
|
||||
|
||||
StartBenchmarkTiming();
|
||||
for (int i = 0; i < iters; ++i) {
|
||||
while (benchState.KeepRunning()) {
|
||||
state.save(SaveFlags::MatrixClip);
|
||||
state.save(SaveFlags::MatrixClip);
|
||||
MicroBench::DoNotOptimize(&state);
|
||||
benchmark::DoNotOptimize(&state);
|
||||
state.restore();
|
||||
state.restore();
|
||||
}
|
||||
StopBenchmarkTiming();
|
||||
}
|
||||
BENCHMARK(BM_CanvasState_saverestore);
|
||||
|
||||
BENCHMARK_NO_ARG(BM_CanvasState_init);
|
||||
void BM_CanvasState_init::Run(int iters) {
|
||||
void BM_CanvasState_init(benchmark::State& benchState) {
|
||||
NullClient client;
|
||||
CanvasState state(client);
|
||||
state.initializeSaveStack(100, 100, 0, 0, 100, 100, Vector3());
|
||||
|
||||
StartBenchmarkTiming();
|
||||
for (int i = 0; i < iters; ++i) {
|
||||
while (benchState.KeepRunning()) {
|
||||
state.initializeSaveStack(100, 100, 0, 0, 100, 100, Vector3());
|
||||
MicroBench::DoNotOptimize(&state);
|
||||
benchmark::DoNotOptimize(&state);
|
||||
}
|
||||
StopBenchmarkTiming();
|
||||
}
|
||||
BENCHMARK(BM_CanvasState_init);
|
||||
|
||||
BENCHMARK_NO_ARG(BM_CanvasState_translate);
|
||||
void BM_CanvasState_translate::Run(int iters) {
|
||||
void BM_CanvasState_translate(benchmark::State& benchState) {
|
||||
NullClient client;
|
||||
CanvasState state(client);
|
||||
state.initializeSaveStack(100, 100, 0, 0, 100, 100, Vector3());
|
||||
|
||||
StartBenchmarkTiming();
|
||||
for (int i = 0; i < iters; ++i) {
|
||||
while (benchState.KeepRunning()) {
|
||||
state.translate(5, 5, 0);
|
||||
MicroBench::DoNotOptimize(&state);
|
||||
benchmark::DoNotOptimize(&state);
|
||||
state.translate(-5, -5, 0);
|
||||
}
|
||||
StopBenchmarkTiming();
|
||||
}
|
||||
BENCHMARK(BM_CanvasState_translate);
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <benchmark/Benchmark.h>
|
||||
#include <benchmark/benchmark.h>
|
||||
|
||||
#include "BakedOpState.h"
|
||||
#include "BakedOpDispatcher.h"
|
||||
@@ -27,7 +27,6 @@
|
||||
#include "tests/common/TestScene.h"
|
||||
#include "tests/common/TestUtils.h"
|
||||
#include "Vector.h"
|
||||
#include "tests/microbench/MicroBench.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
@@ -62,38 +61,34 @@ static std::vector<sp<RenderNode>> createTestNodeList() {
|
||||
return vec;
|
||||
}
|
||||
|
||||
BENCHMARK_NO_ARG(BM_FrameBuilder_defer);
|
||||
void BM_FrameBuilder_defer::Run(int iters) {
|
||||
void BM_FrameBuilder_defer(benchmark::State& state) {
|
||||
auto nodes = createTestNodeList();
|
||||
StartBenchmarkTiming();
|
||||
for (int i = 0; i < iters; i++) {
|
||||
while (state.KeepRunning()) {
|
||||
FrameBuilder frameBuilder(sEmptyLayerUpdateQueue, SkRect::MakeWH(100, 200), 100, 200,
|
||||
nodes, sLightGeometry, nullptr);
|
||||
MicroBench::DoNotOptimize(&frameBuilder);
|
||||
benchmark::DoNotOptimize(&frameBuilder);
|
||||
}
|
||||
StopBenchmarkTiming();
|
||||
}
|
||||
BENCHMARK(BM_FrameBuilder_defer);
|
||||
|
||||
BENCHMARK_NO_ARG(BM_FrameBuilder_deferAndRender);
|
||||
void BM_FrameBuilder_deferAndRender::Run(int iters) {
|
||||
TestUtils::runOnRenderThread([this, iters](RenderThread& thread) {
|
||||
void BM_FrameBuilder_deferAndRender(benchmark::State& state) {
|
||||
TestUtils::runOnRenderThread([&state](RenderThread& thread) {
|
||||
auto nodes = createTestNodeList();
|
||||
|
||||
RenderState& renderState = thread.renderState();
|
||||
Caches& caches = Caches::getInstance();
|
||||
|
||||
StartBenchmarkTiming();
|
||||
for (int i = 0; i < iters; i++) {
|
||||
while (state.KeepRunning()) {
|
||||
FrameBuilder frameBuilder(sEmptyLayerUpdateQueue, SkRect::MakeWH(100, 200), 100, 200,
|
||||
nodes, sLightGeometry, nullptr);
|
||||
|
||||
BakedOpRenderer renderer(caches, renderState, true, sLightInfo);
|
||||
frameBuilder.replayBakedOps<BakedOpDispatcher>(renderer);
|
||||
MicroBench::DoNotOptimize(&renderer);
|
||||
benchmark::DoNotOptimize(&renderer);
|
||||
}
|
||||
StopBenchmarkTiming();
|
||||
});
|
||||
}
|
||||
BENCHMARK(BM_FrameBuilder_deferAndRender);
|
||||
|
||||
static std::vector<sp<RenderNode>> getSyncedSceneNodes(const char* sceneName) {
|
||||
gDisplay = getBuiltInDisplay(); // switch to real display if present
|
||||
@@ -113,47 +108,41 @@ static std::vector<sp<RenderNode>> getSyncedSceneNodes(const char* sceneName) {
|
||||
return nodes;
|
||||
}
|
||||
|
||||
static void benchDeferScene(testing::Benchmark& benchmark, int iters, const char* sceneName) {
|
||||
static auto SCENES = {
|
||||
"listview",
|
||||
};
|
||||
|
||||
void BM_FrameBuilder_defer_scene(benchmark::State& state) {
|
||||
const char* sceneName = *(SCENES.begin() + state.range_x());
|
||||
state.SetLabel(sceneName);
|
||||
auto nodes = getSyncedSceneNodes(sceneName);
|
||||
benchmark.StartBenchmarkTiming();
|
||||
for (int i = 0; i < iters; i++) {
|
||||
while (state.KeepRunning()) {
|
||||
FrameBuilder frameBuilder(sEmptyLayerUpdateQueue,
|
||||
SkRect::MakeWH(gDisplay.w, gDisplay.h), gDisplay.w, gDisplay.h,
|
||||
nodes, sLightGeometry, nullptr);
|
||||
MicroBench::DoNotOptimize(&frameBuilder);
|
||||
benchmark::DoNotOptimize(&frameBuilder);
|
||||
}
|
||||
benchmark.StopBenchmarkTiming();
|
||||
}
|
||||
BENCHMARK(BM_FrameBuilder_defer_scene)->DenseRange(0, SCENES.size() - 1);
|
||||
|
||||
static void benchDeferAndRenderScene(testing::Benchmark& benchmark,
|
||||
int iters, const char* sceneName) {
|
||||
TestUtils::runOnRenderThread([&benchmark, iters, sceneName](RenderThread& thread) {
|
||||
void BM_FrameBuilder_deferAndRender_scene(benchmark::State& state) {
|
||||
TestUtils::runOnRenderThread([&state](RenderThread& thread) {
|
||||
const char* sceneName = *(SCENES.begin() + state.range_x());
|
||||
state.SetLabel(sceneName);
|
||||
auto nodes = getSyncedSceneNodes(sceneName);
|
||||
|
||||
RenderState& renderState = thread.renderState();
|
||||
Caches& caches = Caches::getInstance();
|
||||
|
||||
benchmark.StartBenchmarkTiming();
|
||||
for (int i = 0; i < iters; i++) {
|
||||
while (state.KeepRunning()) {
|
||||
FrameBuilder frameBuilder(sEmptyLayerUpdateQueue,
|
||||
SkRect::MakeWH(gDisplay.w, gDisplay.h), gDisplay.w, gDisplay.h,
|
||||
nodes, sLightGeometry, nullptr);
|
||||
|
||||
BakedOpRenderer renderer(caches, renderState, true, sLightInfo);
|
||||
frameBuilder.replayBakedOps<BakedOpDispatcher>(renderer);
|
||||
MicroBench::DoNotOptimize(&renderer);
|
||||
benchmark::DoNotOptimize(&renderer);
|
||||
}
|
||||
benchmark.StopBenchmarkTiming();
|
||||
});
|
||||
}
|
||||
|
||||
BENCHMARK_NO_ARG(BM_FrameBuilder_listview_defer);
|
||||
void BM_FrameBuilder_listview_defer::Run(int iters) {
|
||||
benchDeferScene(*this, iters, "listview");
|
||||
}
|
||||
|
||||
BENCHMARK_NO_ARG(BM_FrameBuilder_listview_deferAndRender);
|
||||
void BM_FrameBuilder_listview_deferAndRender::Run(int iters) {
|
||||
benchDeferAndRenderScene(*this, iters, "listview");
|
||||
}
|
||||
|
||||
BENCHMARK(BM_FrameBuilder_deferAndRender_scene)->DenseRange(0, SCENES.size() - 1);
|
||||
|
||||
@@ -14,9 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <benchmark/Benchmark.h>
|
||||
#include <benchmark/benchmark.h>
|
||||
|
||||
#include "tests/microbench/MicroBench.h"
|
||||
#include "utils/LinearAllocator.h"
|
||||
|
||||
#include <vector>
|
||||
@@ -24,30 +23,26 @@
|
||||
using namespace android;
|
||||
using namespace android::uirenderer;
|
||||
|
||||
BENCHMARK_NO_ARG(BM_LinearStdAllocator_vectorBaseline);
|
||||
void BM_LinearStdAllocator_vectorBaseline::Run(int iters) {
|
||||
StartBenchmarkTiming();
|
||||
for (int i = 0; i < iters; i++) {
|
||||
static void BM_LinearStdAllocator_vectorBaseline(benchmark::State& state) {
|
||||
while (state.KeepRunning()) {
|
||||
std::vector<char> v;
|
||||
for (int j = 0; j < 200; j++) {
|
||||
v.push_back(j);
|
||||
}
|
||||
MicroBench::DoNotOptimize(&v);
|
||||
benchmark::DoNotOptimize(&v);
|
||||
}
|
||||
StopBenchmarkTiming();
|
||||
}
|
||||
BENCHMARK(BM_LinearStdAllocator_vectorBaseline);
|
||||
|
||||
BENCHMARK_NO_ARG(BM_LinearStdAllocator_vector);
|
||||
void BM_LinearStdAllocator_vector::Run(int iters) {
|
||||
StartBenchmarkTiming();
|
||||
for (int i = 0; i < iters; i++) {
|
||||
static void BM_LinearStdAllocator_vector(benchmark::State& state) {
|
||||
while (state.KeepRunning()) {
|
||||
LinearAllocator la;
|
||||
LinearStdAllocator<void*> stdAllocator(la);
|
||||
std::vector<char, LinearStdAllocator<char> > v(stdAllocator);
|
||||
for (int j = 0; j < 200; j++) {
|
||||
v.push_back(j);
|
||||
}
|
||||
MicroBench::DoNotOptimize(&v);
|
||||
benchmark::DoNotOptimize(&v);
|
||||
}
|
||||
StopBenchmarkTiming();
|
||||
}
|
||||
BENCHMARK(BM_LinearStdAllocator_vector);
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <benchmark/Benchmark.h>
|
||||
#include <benchmark/benchmark.h>
|
||||
|
||||
#include "PathParser.h"
|
||||
#include "VectorDrawable.h"
|
||||
@@ -26,26 +26,26 @@ using namespace android::uirenderer;
|
||||
|
||||
static const char* sPathString = "M 1 1 m 2 2, l 3 3 L 3 3 H 4 h4 V5 v5, Q6 6 6 6 q 6 6 6 6t 7 7 T 7 7 C 8 8 8 8 8 8 c 8 8 8 8 8 8 S 9 9 9 9 s 9 9 9 9 A 10 10 0 1 1 10 10 a 10 10 0 1 1 10 10";
|
||||
|
||||
BENCHMARK_NO_ARG(BM_PathParser_parseStringPathForSkPath);
|
||||
void BM_PathParser_parseStringPathForSkPath::Run(int iter) {
|
||||
void BM_PathParser_parseStringPathForSkPath(benchmark::State& state) {
|
||||
SkPath skPath;
|
||||
size_t length = strlen(sPathString);
|
||||
PathParser::ParseResult result;
|
||||
StartBenchmarkTiming();
|
||||
for (int i = 0; i < iter; i++) {
|
||||
while (state.KeepRunning()) {
|
||||
PathParser::parseStringForSkPath(&skPath, &result, sPathString, length);
|
||||
benchmark::DoNotOptimize(&result);
|
||||
benchmark::DoNotOptimize(&skPath);
|
||||
}
|
||||
StopBenchmarkTiming();
|
||||
}
|
||||
BENCHMARK(BM_PathParser_parseStringPathForSkPath);
|
||||
|
||||
BENCHMARK_NO_ARG(BM_PathParser_parseStringPathForPathData);
|
||||
void BM_PathParser_parseStringPathForPathData::Run(int iter) {
|
||||
void BM_PathParser_parseStringPathForPathData(benchmark::State& state) {
|
||||
size_t length = strlen(sPathString);
|
||||
PathData outData;
|
||||
PathParser::ParseResult result;
|
||||
StartBenchmarkTiming();
|
||||
for (int i = 0; i < iter; i++) {
|
||||
while (state.KeepRunning()) {
|
||||
PathParser::getPathDataFromString(&outData, &result, sPathString, length);
|
||||
benchmark::DoNotOptimize(&result);
|
||||
benchmark::DoNotOptimize(&outData);
|
||||
}
|
||||
StopBenchmarkTiming();
|
||||
}
|
||||
BENCHMARK(BM_PathParser_parseStringPathForPathData);
|
||||
|
||||
@@ -14,14 +14,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <benchmark/Benchmark.h>
|
||||
#include <benchmark/benchmark.h>
|
||||
|
||||
#include "Matrix.h"
|
||||
#include "Rect.h"
|
||||
#include "Vector.h"
|
||||
#include "VertexBuffer.h"
|
||||
#include "TessellationCache.h"
|
||||
#include "tests/microbench/MicroBench.h"
|
||||
|
||||
#include <SkPath.h>
|
||||
|
||||
@@ -78,39 +77,35 @@ static inline void tessellateShadows(ShadowTestData& testData, bool opaque,
|
||||
testData.lightRadius, *ambient, *spot);
|
||||
}
|
||||
|
||||
BENCHMARK_NO_ARG(BM_TessellateShadows_roundrect_opaque);
|
||||
void BM_TessellateShadows_roundrect_opaque::Run(int iters) {
|
||||
void BM_TessellateShadows_roundrect_opaque(benchmark::State& state) {
|
||||
ShadowTestData shadowData;
|
||||
createShadowTestData(&shadowData);
|
||||
SkPath path;
|
||||
path.addRoundRect(SkRect::MakeWH(100, 100), 5, 5);
|
||||
|
||||
StartBenchmarkTiming();
|
||||
for (int i = 0; i < iters; i++) {
|
||||
while (state.KeepRunning()) {
|
||||
VertexBuffer ambient;
|
||||
VertexBuffer spot;
|
||||
tessellateShadows(shadowData, true, path, &ambient, &spot);
|
||||
MicroBench::DoNotOptimize(&ambient);
|
||||
MicroBench::DoNotOptimize(&spot);
|
||||
benchmark::DoNotOptimize(&ambient);
|
||||
benchmark::DoNotOptimize(&spot);
|
||||
}
|
||||
StopBenchmarkTiming();
|
||||
}
|
||||
BENCHMARK(BM_TessellateShadows_roundrect_opaque);
|
||||
|
||||
BENCHMARK_NO_ARG(BM_TessellateShadows_roundrect_translucent);
|
||||
void BM_TessellateShadows_roundrect_translucent::Run(int iters) {
|
||||
void BM_TessellateShadows_roundrect_translucent(benchmark::State& state) {
|
||||
ShadowTestData shadowData;
|
||||
createShadowTestData(&shadowData);
|
||||
SkPath path;
|
||||
path.reset();
|
||||
path.addRoundRect(SkRect::MakeLTRB(0, 0, 100, 100), 5, 5);
|
||||
|
||||
StartBenchmarkTiming();
|
||||
for (int i = 0; i < iters; i++) {
|
||||
while (state.KeepRunning()) {
|
||||
std::unique_ptr<VertexBuffer> ambient(new VertexBuffer);
|
||||
std::unique_ptr<VertexBuffer> spot(new VertexBuffer);
|
||||
tessellateShadows(shadowData, false, path, ambient.get(), spot.get());
|
||||
MicroBench::DoNotOptimize(ambient.get());
|
||||
MicroBench::DoNotOptimize(spot.get());
|
||||
benchmark::DoNotOptimize(ambient.get());
|
||||
benchmark::DoNotOptimize(spot.get());
|
||||
}
|
||||
StopBenchmarkTiming();
|
||||
}
|
||||
BENCHMARK(BM_TessellateShadows_roundrect_translucent);
|
||||
|
||||
@@ -14,12 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <benchmark/Benchmark.h>
|
||||
#include <benchmark/benchmark.h>
|
||||
|
||||
#include "thread/Task.h"
|
||||
#include "thread/TaskManager.h"
|
||||
#include "thread/TaskProcessor.h"
|
||||
#include "tests/microbench/MicroBench.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
@@ -39,55 +38,51 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BENCHMARK_NO_ARG(BM_TaskManager_allocateTask);
|
||||
void BM_TaskManager_allocateTask::Run(int iters) {
|
||||
void BM_TaskManager_allocateTask(benchmark::State& state) {
|
||||
std::vector<sp<TrivialTask> > tasks;
|
||||
tasks.reserve(iters);
|
||||
tasks.reserve(state.max_iterations);
|
||||
|
||||
StartBenchmarkTiming();
|
||||
for (int i = 0; i < iters; i++) {
|
||||
while (state.KeepRunning()) {
|
||||
tasks.emplace_back(new TrivialTask);
|
||||
MicroBench::DoNotOptimize(tasks.back());
|
||||
benchmark::DoNotOptimize(tasks.back());
|
||||
}
|
||||
StopBenchmarkTiming();
|
||||
}
|
||||
BENCHMARK(BM_TaskManager_allocateTask);
|
||||
|
||||
BENCHMARK_NO_ARG(BM_TaskManager_enqueueTask);
|
||||
void BM_TaskManager_enqueueTask::Run(int iters) {
|
||||
void BM_TaskManager_enqueueTask(benchmark::State& state) {
|
||||
TaskManager taskManager;
|
||||
sp<TrivialProcessor> processor(new TrivialProcessor(&taskManager));
|
||||
std::vector<sp<TrivialTask> > tasks;
|
||||
tasks.reserve(iters);
|
||||
tasks.reserve(state.max_iterations);
|
||||
|
||||
StartBenchmarkTiming();
|
||||
for (int i = 0; i < iters; i++) {
|
||||
while (state.KeepRunning()) {
|
||||
tasks.emplace_back(new TrivialTask);
|
||||
MicroBench::DoNotOptimize(tasks.back());
|
||||
benchmark::DoNotOptimize(tasks.back());
|
||||
processor->add(tasks.back());
|
||||
}
|
||||
StopBenchmarkTiming();
|
||||
|
||||
for (sp<TrivialTask>& task : tasks) {
|
||||
task->getResult();
|
||||
}
|
||||
}
|
||||
BENCHMARK(BM_TaskManager_enqueueTask);
|
||||
|
||||
BENCHMARK_NO_ARG(BM_TaskManager_enqueueRunDeleteTask);
|
||||
void BM_TaskManager_enqueueRunDeleteTask::Run(int iters) {
|
||||
void BM_TaskManager_enqueueRunDeleteTask(benchmark::State& state) {
|
||||
TaskManager taskManager;
|
||||
sp<TrivialProcessor> processor(new TrivialProcessor(&taskManager));
|
||||
std::vector<sp<TrivialTask> > tasks;
|
||||
tasks.reserve(iters);
|
||||
tasks.reserve(state.max_iterations);
|
||||
|
||||
StartBenchmarkTiming();
|
||||
for (int i = 0; i < iters; i++) {
|
||||
while (state.KeepRunning()) {
|
||||
tasks.emplace_back(new TrivialTask);
|
||||
MicroBench::DoNotOptimize(tasks.back());
|
||||
benchmark::DoNotOptimize(tasks.back());
|
||||
processor->add(tasks.back());
|
||||
}
|
||||
state.ResumeTiming();
|
||||
for (sp<TrivialTask>& task : tasks) {
|
||||
MicroBench::DoNotOptimize(task->getResult());
|
||||
benchmark::DoNotOptimize(task->getResult());
|
||||
}
|
||||
tasks.clear();
|
||||
StopBenchmarkTiming();
|
||||
state.PauseTiming();
|
||||
}
|
||||
BENCHMARK(BM_TaskManager_enqueueRunDeleteTask);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2015 The Android Open Source Project
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,23 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MICROBENCH_MICROBENCH_H
|
||||
#define MICROBENCH_MICROBENCH_H
|
||||
|
||||
namespace android {
|
||||
namespace uirenderer {
|
||||
#include <benchmark/benchmark.h>
|
||||
|
||||
#define NO_INLINE __attribute__ ((noinline))
|
||||
|
||||
class MicroBench {
|
||||
public:
|
||||
template <class Tp>
|
||||
static inline void DoNotOptimize(Tp const& value) {
|
||||
asm volatile("" : "+rm" (const_cast<Tp&>(value)));
|
||||
}
|
||||
};
|
||||
|
||||
} /* namespace uirenderer */
|
||||
} /* namespace android */
|
||||
|
||||
#endif /* MICROBENCH_MICROBENCH_H */
|
||||
BENCHMARK_MAIN();
|
||||
Reference in New Issue
Block a user