1 /*
2  * Copyright (C) 2017 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 
17 #include "androidfw/AssetManager.h"
18 #include "androidfw/ResourceTypes.h"
19 
20 #include "BenchmarkHelpers.h"
21 #include "TestHelpers.h"
22 #include "data/sparse/R.h"
23 
24 namespace sparse = com::android::sparse;
25 
26 namespace android {
27 
BM_SparseEntryGetResourceSparseSmall(benchmark::State & state)28 static void BM_SparseEntryGetResourceSparseSmall(benchmark::State& state) {
29   ResTable_config config;
30   memset(&config, 0, sizeof(config));
31   config.sdkVersion = 26;
32   GetResourceBenchmarkOld({GetTestDataPath() + "/sparse/sparse.apk"}, &config,
33                           sparse::R::integer::foo_9, state);
34 }
35 BENCHMARK(BM_SparseEntryGetResourceSparseSmall);
36 
BM_SparseEntryGetResourceNotSparseSmall(benchmark::State & state)37 static void BM_SparseEntryGetResourceNotSparseSmall(benchmark::State& state) {
38   ResTable_config config;
39   memset(&config, 0, sizeof(config));
40   config.sdkVersion = 26;
41   GetResourceBenchmarkOld({GetTestDataPath() + "/sparse/not_sparse.apk"}, &config,
42                           sparse::R::integer::foo_9, state);
43 }
44 BENCHMARK(BM_SparseEntryGetResourceNotSparseSmall);
45 
BM_SparseEntryGetResourceSparseLarge(benchmark::State & state)46 static void BM_SparseEntryGetResourceSparseLarge(benchmark::State& state) {
47   ResTable_config config;
48   memset(&config, 0, sizeof(config));
49   config.sdkVersion = 26;
50   GetResourceBenchmarkOld({GetTestDataPath() + "/sparse/sparse.apk"}, &config,
51                           sparse::R::string::foo_999, state);
52 }
53 BENCHMARK(BM_SparseEntryGetResourceSparseLarge);
54 
BM_SparseEntryGetResourceNotSparseLarge(benchmark::State & state)55 static void BM_SparseEntryGetResourceNotSparseLarge(benchmark::State& state) {
56   ResTable_config config;
57   memset(&config, 0, sizeof(config));
58   config.sdkVersion = 26;
59   GetResourceBenchmarkOld({GetTestDataPath() + "/sparse/not_sparse.apk"}, &config,
60                           sparse::R::string::foo_999, state);
61 }
62 BENCHMARK(BM_SparseEntryGetResourceNotSparseLarge);
63 
64 }  // namespace android
65