From f59cb788ba6d06d13b440b2b7d3f9d4480052c2f Mon Sep 17 00:00:00 2001 From: Doris Liu Date: Tue, 10 Nov 2015 10:36:17 -0800 Subject: [PATCH] Add microbench for PathParser Change-Id: I95d6c3153480e3ea56032ffe73707110186fbb0f --- libs/hwui/Android.mk | 1 + libs/hwui/microbench/PathParserBench.cpp | 36 ++++++++++++++++++++++++ libs/hwui/microbench/how_to_run.txt | 4 +++ 3 files changed, 41 insertions(+) create mode 100644 libs/hwui/microbench/PathParserBench.cpp create mode 100755 libs/hwui/microbench/how_to_run.txt diff --git a/libs/hwui/Android.mk b/libs/hwui/Android.mk index 95e4e77371a8b..5cdd7232923cc 100644 --- a/libs/hwui/Android.mk +++ b/libs/hwui/Android.mk @@ -275,6 +275,7 @@ LOCAL_STATIC_LIBRARIES := libbenchmark libbase LOCAL_SRC_FILES += \ microbench/DisplayListCanvasBench.cpp \ microbench/LinearAllocatorBench.cpp \ + microbench/PathParserBench.cpp \ microbench/ShadowBench.cpp ifeq (true, $(HWUI_NEW_OPS)) diff --git a/libs/hwui/microbench/PathParserBench.cpp b/libs/hwui/microbench/PathParserBench.cpp new file mode 100644 index 0000000000000..198035edc2923 --- /dev/null +++ b/libs/hwui/microbench/PathParserBench.cpp @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2015 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include "PathParser.h" + +#include + +using namespace android; +using namespace android::uirenderer; + +BENCHMARK_NO_ARG(BM_PathParser_parseStringPath); +void BM_PathParser_parseStringPath::Run(int iter) { + const char* pathString = "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"; + SkPath skPath; + size_t length = strlen(pathString); + StartBenchmarkTiming(); + for (int i = 0; i < iter; i++) { + PathParser::parseStringForSkPath(&skPath, pathString, length); + } + StopBenchmarkTiming(); +} diff --git a/libs/hwui/microbench/how_to_run.txt b/libs/hwui/microbench/how_to_run.txt new file mode 100755 index 0000000000000..e6f80b2782763 --- /dev/null +++ b/libs/hwui/microbench/how_to_run.txt @@ -0,0 +1,4 @@ +mmm -j8 frameworks/base/libs/hwui && +adb push $ANDROID_PRODUCT_OUT/data/local/tmp/hwuimicro \ + /data/local/tmp/hwuimicro && + adb shell /data/local/tmp/hwuimicro