/** * Runtime benchmarking * (C) 2008 Jack Lloyd */ #ifndef BOTAN_RUNTIME_BENCHMARK_H__ #define BOTAN_RUNTIME_BENCHMARK_H__ #include #include #include #include #include /** * 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 #elif defined(BOTAN_HAS_TIMER_UNIX) #include #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 /* I have not had good success using clock(), the results seem * pretty bogus, but as a last resort it works. */ 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 */ std::map algorithm_benchmark(const std::string& name, u32bit milliseconds, Timer& timer, RandomNumberGenerator& rng, Algorithm_Factory& af); } #endif