Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
libcxx/benchmarks/format_itoa_character_width.bench.cpp
- This file was added.
//===----------------------------------------------------------------------===// | |||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |||||
// See https://llvm.org/LICENSE.txt for license information. | |||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |||||
// | |||||
//===----------------------------------------------------------------------===// | |||||
#include "FormatItoa.h" | |||||
template <class T> | |||||
static void BM_format_character_width_base_10(benchmark::State& state) { | |||||
std::array<T, batch_size> values = create_array<T>(state.range(0)); | |||||
while (state.KeepRunningBatch(batch_size)) | |||||
for (auto value : values) | |||||
benchmark::DoNotOptimize(std::__character_width_base_10(value)); | |||||
} | |||||
BENCHMARK_TEMPLATE(BM_format_character_width_base_10, uint32_t) | |||||
->DenseRange(1, digits_max<uint32_t>, 1); | |||||
BENCHMARK_TEMPLATE(BM_format_character_width_base_10, int32_t) | |||||
->DenseRange(1, digits_max<int32_t>, 1); | |||||
BENCHMARK_TEMPLATE(BM_format_character_width_base_10, uint64_t) | |||||
->DenseRange(1, digits_max<uint64_t>); | |||||
BENCHMARK_TEMPLATE(BM_format_character_width_base_10, int64_t) | |||||
->DenseRange(1, digits_max<int64_t>, 1); | |||||
#ifndef _LIBCPP_HAS_NO_INT128 | |||||
BENCHMARK_TEMPLATE(BM_format_character_width_base_10, __uint128_t) | |||||
->DenseRange(1, digits_max<__uint128_t>, 1); | |||||
BENCHMARK_TEMPLATE(BM_format_character_width_base_10, __int128_t) | |||||
->DenseRange(1, digits_max<__int128_t>, 1); | |||||
#endif | |||||
int main(int argc, char** argv) { | |||||
benchmark::Initialize(&argc, argv); | |||||
if (benchmark::ReportUnrecognizedArguments(argc, argv)) | |||||
return 1; | |||||
benchmark::RunSpecifiedBenchmarks(); | |||||
} |