blob: d6dc07dfb704eccbdf74ecbe83f710956df94216 [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
27static void BM_SparseEntryGetResourceSparseSmall(benchmark::State& state) {
28 ResTable_config config;
29 memset(&config, 0, sizeof(config));
30 config.sdkVersion = 26;
31 GetResourceBenchmarkOld({GetTestDataPath() + "/sparse/sparse.apk"}, &config,
32 sparse::R::integer::foo_9, state);
33}
34BENCHMARK(BM_SparseEntryGetResourceSparseSmall);
35
36static void BM_SparseEntryGetResourceNotSparseSmall(benchmark::State& state) {
37 ResTable_config config;
38 memset(&config, 0, sizeof(config));
39 config.sdkVersion = 26;
40 GetResourceBenchmarkOld({GetTestDataPath() + "/sparse/not_sparse.apk"}, &config,
41 sparse::R::integer::foo_9, state);
42}
43BENCHMARK(BM_SparseEntryGetResourceNotSparseSmall);
44
45static void BM_SparseEntryGetResourceSparseLarge(benchmark::State& state) {
46 ResTable_config config;
47 memset(&config, 0, sizeof(config));
48 config.sdkVersion = 26;
49 GetResourceBenchmarkOld({GetTestDataPath() + "/sparse/sparse.apk"}, &config,
50 sparse::R::string::foo_999, state);
51}
52BENCHMARK(BM_SparseEntryGetResourceSparseLarge);
53
54static void BM_SparseEntryGetResourceNotSparseLarge(benchmark::State& state) {
55 ResTable_config config;
56 memset(&config, 0, sizeof(config));
57 config.sdkVersion = 26;
58 GetResourceBenchmarkOld({GetTestDataPath() + "/sparse/not_sparse.apk"}, &config,
59 sparse::R::string::foo_999, state);
60}
61BENCHMARK(BM_SparseEntryGetResourceNotSparseLarge);
62
63} // namespace android