blob: c23d4996df496d334803e336d6f229210a2d41c4 [file] [log] [blame]
Steven Morelandc732c032019-09-03 18:04:50 -07001/*
2 * Copyright (C) 2019 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 <benchmark/benchmark.h>
18#include <utils/Vector.h>
19#include <vector>
20
21void BM_fill_android_vector(benchmark::State& state) {
22 android::Vector<char> v;
23 while (state.KeepRunning()) {
24 v.push('A');
25 }
26}
27BENCHMARK(BM_fill_android_vector);
28
29void BM_fill_std_vector(benchmark::State& state) {
30 std::vector<char> v;
31 while (state.KeepRunning()) {
32 v.push_back('A');
33 }
34}
35BENCHMARK(BM_fill_std_vector);
36
37void BM_prepend_android_vector(benchmark::State& state) {
38 android::Vector<char> v;
39 while (state.KeepRunning()) {
40 v.insertAt('A', 0);
41 }
42}
43BENCHMARK(BM_prepend_android_vector);
44
45void BM_prepend_std_vector(benchmark::State& state) {
46 std::vector<char> v;
47 while (state.KeepRunning()) {
48 v.insert(v.begin(), 'A');
49 }
50}
51BENCHMARK(BM_prepend_std_vector);
52
53BENCHMARK_MAIN();