SparseEntry_bench.cpp revision c8f71aa67ea599cb80205496cb67e9e7a121299c
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 24namespace sparse = com::android::sparse; 25 26namespace android { 27 28static 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} 35BENCHMARK(BM_SparseEntryGetResourceSparseSmall); 36 37static 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} 44BENCHMARK(BM_SparseEntryGetResourceNotSparseSmall); 45 46static 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} 53BENCHMARK(BM_SparseEntryGetResourceSparseLarge); 54 55static 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} 62BENCHMARK(BM_SparseEntryGetResourceNotSparseLarge); 63 64} // namespace android 65