| #include "benchmark/benchmark.h" | |
| #include "androidfw/Util.h" | |
| #include <string> | |
| namespace android { | |
| static void BM_ModifiedUtf8ToUtf8_Normal(benchmark::State& state) { | |
| std::string input(state.range(0), 'a'); | |
| for (auto _ : state) { | |
| benchmark::DoNotOptimize(util::ModifiedUtf8ToUtf8(input)); | |
| } | |
| } | |
| BENCHMARK(BM_ModifiedUtf8ToUtf8_Normal)->Range(10, 100000); | |
| static void BM_ModifiedUtf8ToUtf8_Modified(benchmark::State& state) { | |
| std::string input(state.range(0), 'a'); | |
| input[input.size() / 2] = '\xC0'; | |
| for (auto _ : state) { | |
| benchmark::DoNotOptimize(util::ModifiedUtf8ToUtf8(input)); | |
| } | |
| } | |
| BENCHMARK(BM_ModifiedUtf8ToUtf8_Modified)->Range(10, 100000); | |
| } // namespace android | |