blob: 3619b7ee83abcbd789e6ccfb32fef0d10ab90d59 [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 "BenchmarkHelpers.h"
18
19#include "android-base/stringprintf.h"
20#include "androidfw/AssetManager.h"
21
22namespace android {
23
24void GetResourceBenchmarkOld(const std::vector<std::string>& paths, const ResTable_config* config,
25 uint32_t resid, benchmark::State& state) {
26 AssetManager assetmanager;
27 for (const std::string& path : paths) {
28 if (!assetmanager.addAssetPath(String8(path.c_str()), nullptr /* cookie */,
29 false /* appAsLib */, false /* isSystemAssets */)) {
30 state.SkipWithError(base::StringPrintf("Failed to load assets %s", path.c_str()).c_str());
31 return;
32 }
33 }
34
35 if (config != nullptr) {
36 assetmanager.setConfiguration(*config);
37 }
38
39 const ResTable& table = assetmanager.getResources(true);
40
41 Res_value value;
42 ResTable_config selected_config;
43 uint32_t flags;
44
45 while (state.KeepRunning()) {
46 table.getResource(resid, &value, false /*may_be_bag*/, 0u /*density*/, &flags,
47 &selected_config);
48 }
49}
50
51} // namespace android