diff options
author | lloyd <[email protected]> | 2008-11-21 16:55:17 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-11-21 16:55:17 +0000 |
commit | 8c885d8fca72e46a27f3f86f3645c780d34596b8 (patch) | |
tree | 4eb64d0c458a47571209d2e038bd4f927684a038 | |
parent | def575a6c23a59237ec9cf944cbf8db0d4b5dc71 (diff) |
Add a typedef in benchmark.h Default_Benchmark_Timer, which checks available
timer alternatives. I realized otherwise each application would be forced
to do the exact same thing, and no reason for that.
-rw-r--r-- | src/benchmark/benchmark.h | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/src/benchmark/benchmark.h b/src/benchmark/benchmark.h index a8193d72d..658e6be7f 100644 --- a/src/benchmark/benchmark.h +++ b/src/benchmark/benchmark.h @@ -12,16 +12,35 @@ #include <map> #include <string> +/** +* Choose some sort of default timer implementation to use, since some +* (like hardware tick counters and current Win32 timer) are not +* reliable for benchmarking. +*/ +#if defined(BOTAN_HAS_TIMER_POSIX) + #include <botan/tm_posix.h> +#elif defined(BOTAN_HAS_TIMER_UNIX) + #include <botan/tm_unix.h> +#endif + namespace Botan { +#if defined(BOTAN_HAS_TIMER_POSIX) + typedef POSIX_Timer Default_Benchmark_Timer; +#elif defined(BOTAN_HAS_TIMER_UNIX) + typedef Unix_Timer Default_Benchmark_Timer; +#else + typedef ANSI_Clock_Timer Default_Benchmark_Timer; +#endif + /** -Algorithm benchmark -@param name the name of the algorithm to test (cipher, hash, or MAC) -@param milliseconds total time for the benchmark to run -@param timer the timer to use -@param rng the rng to use to generate random inputs -@param af the algorithm factory used to create objects -@returns results a map from provider to speed in mebibytes per second +* Algorithm benchmark +* @param name the name of the algorithm to test (cipher, hash, or MAC) +* @param milliseconds total time for the benchmark to run +* @param timer the timer to use +* @param rng the rng to use to generate random inputs +* @param af the algorithm factory used to create objects +* @returns results a map from provider to speed in mebibytes per second */ std::map<std::string, double> algorithm_benchmark(const std::string& name, @@ -32,5 +51,4 @@ algorithm_benchmark(const std::string& name, } - #endif |