19 #include <glog/logging.h> 21 #include <type_traits> 23 template <
typename ValueT>
26 return static_cast<ValueT>(
27 static_cast<UnsignedT
>(
a) + static_cast<UnsignedT>(b));
30 template <
typename ValueT>
33 return static_cast<ValueT>(
34 static_cast<UnsignedT
>(
a) - static_cast<UnsignedT>(b));
37 template <
typename ValueT,
typename Op>
39 auto kMid = (kMin + kMax) / 2;
42 for (
ValueT a = kMin;
a < kMin + 100;
a++) {
43 for (
ValueT b = kMin;
b < kMin + 100;
b++) {
51 for (
ValueT a = kMin;
a < kMin + 100;
a++) {
52 for (
ValueT b = kMid - 50;
b < kMid + 50;
b++) {
60 for (
ValueT a = kMin;
a < kMin + 100;
a++) {
61 for (
ValueT b = kMax - 100;
b < kMax;
b++) {
69 for (
ValueT a = kMid - 50;
a < kMid + 50;
a++) {
70 for (
ValueT b = kMin;
b < kMin + 100;
b++) {
78 for (
ValueT a = kMid - 50;
a < kMid + 50;
a++) {
79 for (
ValueT b = kMid - 50;
b < kMid + 50;
b++) {
87 for (
ValueT a = kMid - 50;
a < kMid + 50;
a++) {
88 for (
ValueT b = kMax - 100;
b < kMax;
b++) {
96 for (
ValueT a = kMax - 100;
a < kMax;
a++) {
97 for (
ValueT b = kMin;
b < kMin + 100;
b++) {
105 for (
ValueT a = kMax - 100;
a < kMax;
a++) {
106 for (
ValueT b = kMid - 50;
b < kMid + 50;
b++) {
114 for (
ValueT a = kMax - 100;
a < kMax;
a++) {
115 for (
ValueT b = kMax - 100;
b < kMax;
b++) {
126 template <
typename ValueT>
133 template <
typename ValueT>
140 template <
typename ValueT>
147 template <
typename ValueT>
154 #define GENERATE_BENCHMARKS_FOR_TYPE(ValueT) \ 155 BENCHMARK_NAMED_PARAM( \ 158 std::numeric_limits<ValueT>::min(), \ 159 std::numeric_limits<ValueT>::max()) \ 160 BENCHMARK_RELATIVE_NAMED_PARAM( \ 163 std::numeric_limits<ValueT>::min(), \ 164 std::numeric_limits<ValueT>::max()) \ 165 BENCHMARK_NAMED_PARAM( \ 168 std::numeric_limits<ValueT>::min(), \ 169 std::numeric_limits<ValueT>::max()) \ 170 BENCHMARK_RELATIVE_NAMED_PARAM( \ 173 std::numeric_limits<ValueT>::min(), \ 174 std::numeric_limits<ValueT>::max()) 179 BENCHMARK_DRAW_LINE();
181 BENCHMARK_DRAW_LINE();
183 BENCHMARK_DRAW_LINE();
185 BENCHMARK_DRAW_LINE();
187 BENCHMARK_DRAW_LINE();
189 BENCHMARK_DRAW_LINE();
193 gflags::ParseCommandLineFlags(&argc, &argv,
true);
constexpr T constexpr_add_overflow_clamped(T a, T b)
void NoOverflowAdd(size_t iterations, ValueT kMin, ValueT kMax)
constexpr To round(std::chrono::duration< Rep, Period > const &d)
#define GENERATE_BENCHMARKS_FOR_TYPE(ValueT)
void Run(size_t iterations, ValueT kMin, ValueT kMax, Op &&op)
constexpr ValueT UBSafeSub(ValueT a, ValueT b)
void Sub(size_t iterations, ValueT kMin, ValueT kMax)
constexpr T constexpr_sub_overflow_clamped(T a, T b)
constexpr ValueT UBSafeAdd(ValueT a, ValueT b)
void NoOverflowSub(size_t iterations, ValueT kMin, ValueT kMax)
void Add(size_t iterations, ValueT kMin, ValueT kMax)
#define BENCHMARK_DRAW_LINE()
auto makeUnpredictable(T &datum) -> typename std::enable_if< !detail::DoNotOptimizeAwayNeedsIndirect< T >::value >::type
auto doNotOptimizeAway(const T &datum) -> typename std::enable_if< !detail::DoNotOptimizeAwayNeedsIndirect< T >::value >::type