blob: b43c4c3b63c1f175e9ea2164103a9fde18743327 [file] [log] [blame]
Doris Liuf59cb782015-11-10 10:36:17 -08001/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
John Reck0418afa32016-03-07 13:24:25 -080017#include <benchmark/benchmark.h>
Doris Liuf59cb782015-11-10 10:36:17 -080018
19#include "PathParser.h"
Doris Liu4bbc2932015-12-01 17:59:40 -080020#include "VectorDrawable.h"
Doris Liuf59cb782015-11-10 10:36:17 -080021
22#include <SkPath.h>
23
24using namespace android;
25using namespace android::uirenderer;
26
Doris Liu804618d2015-11-16 22:48:34 -080027static 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";
28
John Reck0418afa32016-03-07 13:24:25 -080029void BM_PathParser_parseStringPathForSkPath(benchmark::State& state) {
Doris Liuf59cb782015-11-10 10:36:17 -080030 SkPath skPath;
Doris Liu804618d2015-11-16 22:48:34 -080031 size_t length = strlen(sPathString);
Doris Liu1e67f082015-11-12 15:57:45 -080032 PathParser::ParseResult result;
John Reck0418afa32016-03-07 13:24:25 -080033 while (state.KeepRunning()) {
Doris Liub35da392016-04-12 11:06:23 -070034 PathParser::parseAsciiStringForSkPath(&skPath, &result, sPathString, length);
John Reck0418afa32016-03-07 13:24:25 -080035 benchmark::DoNotOptimize(&result);
36 benchmark::DoNotOptimize(&skPath);
Doris Liu804618d2015-11-16 22:48:34 -080037 }
Doris Liu804618d2015-11-16 22:48:34 -080038}
John Reck0418afa32016-03-07 13:24:25 -080039BENCHMARK(BM_PathParser_parseStringPathForSkPath);
Doris Liu804618d2015-11-16 22:48:34 -080040
John Reck0418afa32016-03-07 13:24:25 -080041void BM_PathParser_parseStringPathForPathData(benchmark::State& state) {
Doris Liu804618d2015-11-16 22:48:34 -080042 size_t length = strlen(sPathString);
43 PathData outData;
44 PathParser::ParseResult result;
John Reck0418afa32016-03-07 13:24:25 -080045 while (state.KeepRunning()) {
Doris Liub35da392016-04-12 11:06:23 -070046 PathParser::getPathDataFromAsciiString(&outData, &result, sPathString, length);
John Reck0418afa32016-03-07 13:24:25 -080047 benchmark::DoNotOptimize(&result);
48 benchmark::DoNotOptimize(&outData);
Doris Liuf59cb782015-11-10 10:36:17 -080049 }
Doris Liuf59cb782015-11-10 10:36:17 -080050}
John Reck0418afa32016-03-07 13:24:25 -080051BENCHMARK(BM_PathParser_parseStringPathForPathData);