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