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 "data/sparse/R.h" 22 23 namespace sparse = com::android::sparse; 24 25 namespace android { 26 27 static void BM_SparseEntryGetResourceOldSparse(benchmark::State& state, uint32_t resid) { 28 ResTable_config config; 29 memset(&config, 0, sizeof(config)); 30 config.sdkVersion = 26; 31 GetResourceBenchmarkOld({GetTestDataPath() + "/sparse/sparse.apk"}, &config, resid, state); 32 } 33 BENCHMARK_CAPTURE(BM_SparseEntryGetResourceOldSparse, Small, sparse::R::integer::foo_9); 34 BENCHMARK_CAPTURE(BM_SparseEntryGetResourceOldSparse, Large, sparse::R::string::foo_999); 35 36 static void BM_SparseEntryGetResourceOldNotSparse(benchmark::State& state, uint32_t resid) { 37 ResTable_config config; 38 memset(&config, 0, sizeof(config)); 39 config.sdkVersion = 26; 40 GetResourceBenchmarkOld({GetTestDataPath() + "/sparse/not_sparse.apk"}, &config, resid, state); 41 } 42 BENCHMARK_CAPTURE(BM_SparseEntryGetResourceOldNotSparse, Small, sparse::R::integer::foo_9); 43 BENCHMARK_CAPTURE(BM_SparseEntryGetResourceOldNotSparse, Large, sparse::R::string::foo_999); 44 45 static void BM_SparseEntryGetResourceSparse(benchmark::State& state, uint32_t resid) { 46 ResTable_config config; 47 memset(&config, 0, sizeof(config)); 48 config.sdkVersion = 26; 49 GetResourceBenchmark({GetTestDataPath() + "/sparse/sparse.apk"}, &config, resid, state); 50 } 51 BENCHMARK_CAPTURE(BM_SparseEntryGetResourceSparse, Small, sparse::R::integer::foo_9); 52 BENCHMARK_CAPTURE(BM_SparseEntryGetResourceSparse, Large, sparse::R::string::foo_999); 53 54 static void BM_SparseEntryGetResourceNotSparse(benchmark::State& state, uint32_t resid) { 55 ResTable_config config; 56 memset(&config, 0, sizeof(config)); 57 config.sdkVersion = 26; 58 GetResourceBenchmark({GetTestDataPath() + "/sparse/not_sparse.apk"}, &config, resid, state); 59 } 60 BENCHMARK_CAPTURE(BM_SparseEntryGetResourceNotSparse, Small, sparse::R::integer::foo_9); 61 BENCHMARK_CAPTURE(BM_SparseEntryGetResourceNotSparse, Large, sparse::R::string::foo_999); 62 63 } // namespace android 64