blob: c9b4ad8af2780ddd211a2711ac1e7c5fc82d2a26 [file] [log] [blame]
Adam Lesinskic8f71aa2017-02-08 07:03:50 -08001/*
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"
Adam Lesinskic8f71aa2017-02-08 07:03:50 -080021#include "data/sparse/R.h"
22
23namespace sparse = com::android::sparse;
24
25namespace android {
26
Adam Lesinski73f6f9d2017-11-14 10:18:05 -080027static void BM_SparseEntryGetResourceOldSparse(benchmark::State& state, uint32_t resid) {
Adam Lesinskic8f71aa2017-02-08 07:03:50 -080028 ResTable_config config;
29 memset(&config, 0, sizeof(config));
30 config.sdkVersion = 26;
Adam Lesinski73f6f9d2017-11-14 10:18:05 -080031 GetResourceBenchmarkOld({GetTestDataPath() + "/sparse/sparse.apk"}, &config, resid, state);
Adam Lesinskic8f71aa2017-02-08 07:03:50 -080032}
Adam Lesinski73f6f9d2017-11-14 10:18:05 -080033BENCHMARK_CAPTURE(BM_SparseEntryGetResourceOldSparse, Small, sparse::R::integer::foo_9);
34BENCHMARK_CAPTURE(BM_SparseEntryGetResourceOldSparse, Large, sparse::R::string::foo_999);
Adam Lesinskic8f71aa2017-02-08 07:03:50 -080035
Adam Lesinski73f6f9d2017-11-14 10:18:05 -080036static void BM_SparseEntryGetResourceOldNotSparse(benchmark::State& state, uint32_t resid) {
Adam Lesinskic8f71aa2017-02-08 07:03:50 -080037 ResTable_config config;
38 memset(&config, 0, sizeof(config));
39 config.sdkVersion = 26;
Adam Lesinski73f6f9d2017-11-14 10:18:05 -080040 GetResourceBenchmarkOld({GetTestDataPath() + "/sparse/not_sparse.apk"}, &config, resid, state);
Adam Lesinskic8f71aa2017-02-08 07:03:50 -080041}
Adam Lesinski73f6f9d2017-11-14 10:18:05 -080042BENCHMARK_CAPTURE(BM_SparseEntryGetResourceOldNotSparse, Small, sparse::R::integer::foo_9);
43BENCHMARK_CAPTURE(BM_SparseEntryGetResourceOldNotSparse, Large, sparse::R::string::foo_999);
Adam Lesinskic8f71aa2017-02-08 07:03:50 -080044
Adam Lesinski73f6f9d2017-11-14 10:18:05 -080045static void BM_SparseEntryGetResourceSparse(benchmark::State& state, uint32_t resid) {
Adam Lesinskic8f71aa2017-02-08 07:03:50 -080046 ResTable_config config;
47 memset(&config, 0, sizeof(config));
48 config.sdkVersion = 26;
Adam Lesinski73f6f9d2017-11-14 10:18:05 -080049 GetResourceBenchmark({GetTestDataPath() + "/sparse/sparse.apk"}, &config, resid, state);
Adam Lesinskic8f71aa2017-02-08 07:03:50 -080050}
Adam Lesinski73f6f9d2017-11-14 10:18:05 -080051BENCHMARK_CAPTURE(BM_SparseEntryGetResourceSparse, Small, sparse::R::integer::foo_9);
52BENCHMARK_CAPTURE(BM_SparseEntryGetResourceSparse, Large, sparse::R::string::foo_999);
Adam Lesinskic8f71aa2017-02-08 07:03:50 -080053
Adam Lesinski73f6f9d2017-11-14 10:18:05 -080054static void BM_SparseEntryGetResourceNotSparse(benchmark::State& state, uint32_t resid) {
Adam Lesinskic8f71aa2017-02-08 07:03:50 -080055 ResTable_config config;
56 memset(&config, 0, sizeof(config));
57 config.sdkVersion = 26;
Adam Lesinski73f6f9d2017-11-14 10:18:05 -080058 GetResourceBenchmark({GetTestDataPath() + "/sparse/not_sparse.apk"}, &config, resid, state);
Adam Lesinskic8f71aa2017-02-08 07:03:50 -080059}
Adam Lesinski73f6f9d2017-11-14 10:18:05 -080060BENCHMARK_CAPTURE(BM_SparseEntryGetResourceNotSparse, Small, sparse::R::integer::foo_9);
61BENCHMARK_CAPTURE(BM_SparseEntryGetResourceNotSparse, Large, sparse::R::string::foo_999);
Adam Lesinskic8f71aa2017-02-08 07:03:50 -080062
63} // namespace android