#pragma region CPL License /* Nuclex Native Framework Copyright (C) 2002-2023 Nuclex Development Labs This library is free software; you can redistribute it and/or modify it under the terms of the IBM Common Public License as published by the IBM Corporation; either version 1.0 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the IBM Common Public License for more details. You should have received a copy of the IBM Common Public License along with this library */ #pragma endregion // CPL License // If the library is compiled as a DLL, this ensures symbols are exported #define NUCLEX_SUPPORT_SOURCE 1 #include "Nuclex/Support/Config.h" #if defined(HAVE_AMDN_ITOA) #include // Arturo Martin-de-Nicolas' quite readable itoa() implementation // https://github.com/amdn/itoa_ljust #include "AmdnLJust-2016/itoa_ljust.h" // Arturo Martin-de-Nicolas' fastest itoa() implementation // https://github.com/amdn/itoa #include "AmdnFast-2016/itoa.h" #include // for std::mt19937 #include // for std::uint32_t, std::uint64_t namespace { // ------------------------------------------------------------------------------------------- // /// Fast random number generator used in the benchmark std::mt19937 randomNumberGenerator32; /// Uniform distribution to make the output cover all possible integers std::uniform_int_distribution randomNumberDistribution32; /// Fast random number generator used in the benchmark std::mt19937_64 randomNumberGenerator64; /// Uniform distribution to make the output cover all possible integers std::uniform_int_distribution randomNumberDistribution64; // ------------------------------------------------------------------------------------------- // } // anonymous namespace namespace Nuclex { namespace Support { namespace Text { // ------------------------------------------------------------------------------------------- // BENCHMARK(Integer32Itoa, NicolasLJust, 1000, 0) { char number[40]; celero::DoNotOptimizeAway( itoa_ljust::itoa( static_cast(randomNumberDistribution32(randomNumberGenerator32)), number ) ); } // ------------------------------------------------------------------------------------------- // BENCHMARK(Integer64Itoa, NicolasLJust, 1000, 0) { char number[40]; celero::DoNotOptimizeAway( itoa_ljust::itoa( static_cast(randomNumberDistribution64(randomNumberGenerator64)), number ) ); } // ------------------------------------------------------------------------------------------- // BENCHMARK(Integer32Itoa, NicolasFast, 1000, 0) { char number[40]; celero::DoNotOptimizeAway( itoa_fwd( static_cast(randomNumberDistribution32(randomNumberGenerator32)), number ) ); } // ------------------------------------------------------------------------------------------- // BENCHMARK(Integer64Itoa, NicolasFast, 1000, 0) { char number[40]; celero::DoNotOptimizeAway( itoa_fwd( static_cast(randomNumberDistribution64(randomNumberGenerator64)), number ) ); } // ------------------------------------------------------------------------------------------- // }}} // namespace Nuclex::Support::Text #endif // defined(HAVE_AMDN_ITOA)