Created
October 2, 2015 09:34
-
-
Save EricWF/29868ce86eaa4a03132d to your computer and use it in GitHub Desktop.
results in 32 bit mode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "benchmark/benchmark.h" | |
| #include <cstdint> | |
| #include <limits> | |
| using namespace benchmark; | |
| typedef std::uint32_t UInt32; | |
| typedef std::uint64_t UInt64; | |
| template <class IntType> | |
| void BM_IntAddingAndComparisons(State& st) { | |
| //Use the upper bits of the IntType to try and defeat the optimizer. | |
| IntType const Iters = 10000000; | |
| IntType const Max = std::numeric_limits<IntType>::max(); | |
| IntType const Stop = Max - Iters; | |
| while (st.KeepRunning()) { | |
| for (IntType i = Stop; i != Max; ++i) { | |
| DoNotOptimize(i); | |
| } | |
| } | |
| } | |
| BENCHMARK_TEMPLATE(BM_IntAddingAndComparisons, UInt32); | |
| BENCHMARK_TEMPLATE(BM_IntAddingAndComparisons, UInt64); | |
| BENCHMARK_MAIN() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Run on (8 X 4228.74 MHz CPU s) | |
| 2015-10-02 03:06:55 | |
| Benchmark Time(ns) CPU(ns) Iterations | |
| ------------------------------------------------------------------- | |
| BM_IntAddingAndComparisons<UInt32> 5063790 5066026 833 | |
| BM_IntAddingAndComparisons<UInt64> 6406909 6406015 665 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment