# # # patch "monotone.cc" # from [7503506de8c31d035c2148cf3431ab7eb49d5c40] # to [932ce84862eab027b416e95c5002da0dd57e99e1] # # patch "sha1.cc" # from [5b5488b7d19a740f70bae5d82c709c9549c5f38d] # to [6e6cf9982a2d8f8297aa1869e4ffc434b33ca0a8] # ============================================================ --- monotone.cc 7503506de8c31d035c2148cf3431ab7eb49d5c40 +++ monotone.cc 932ce84862eab027b416e95c5002da0dd57e99e1 @@ -228,9 +228,20 @@ cpp_main(int argc, char ** argv) F("This monotone binary requires Botan 1.6.3 or newer.")); N(linked_botan_version <= BOTAN_VERSION_CODE_FOR(1,7,6), F("This monotone binary does not work with Botan newer than 1.7.6."); +#elif BOTAN_VERSION_CODE <= BOTAN_VERSION_CODE_FOR(1,7,22) + N(linked_botan_version > BOTAN_VERSION_CODE_FOR(1,7,6), + F("This monotone binary requires Botan 1.7.7 or newer.")); + // While compiling against 1.7.22 or newer is recommended, because + // it enables new features of Botan, the monotone binary compiled + // against Botan 1.7.21 and before should still work with newer Botan + // versions, including all of the stable branch 1.8.x. + N(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,9,0), + F("This monotone binary does not work with Botan 1.9.x."); #else N(linked_botan_version > BOTAN_VERSION_CODE_FOR(1,7,22), F("This monotone binary requires Botan 1.7.22 or newer.")); + N(linked_botan_version < BOTAN_VERSION_CODE_FOR(1,9,0), + F("This monotone binary does not work with Botan 1.9.x."); #endif app_state app; ============================================================ --- sha1.cc 5b5488b7d19a740f70bae5d82c709c9549c5f38d +++ sha1.cc 6e6cf9982a2d8f8297aa1869e4ffc434b33ca0a8 @@ -14,6 +14,32 @@ #include #include +// Botan 1.7.22 and 1.8.x specific sha1 benchmarking code uses botan's +// own timer and measures botan's different SHA1 providers, instead of +// only measuring one. +#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,7,22) + #include + #include + + // Choose a timer implementation + #if defined(BOTAN_HAS_TIMER_POSIX) + #include + typedef Botan::POSIX_Timer benchmark_timer_class; + #elif defined(BOTAN_HAS_TIMER_UNIX) + #include + typedef Botan::Unix_Timer benchmark_timer_class; + #elif defined(BOTAN_HAS_TIMER_WIN32) + #include + typedef Botan::Win32_Timer benchmark_timer_class; + #elif + /* This uses ANSI clock and gives somewhat bogus results + due to the poor resolution + */ + typedef Botan::Timer benchmark_timer_class; + #endif + +#endif + #include "sanity.hh" #include "ui.hh" #include "platform.hh" @@ -28,6 +54,25 @@ CMD_HIDDEN(benchmark_sha1, "benchmark_sh options::opts::none) { P(F("Benchmarking botan's SHA-1 core")); + +#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,7,22) + benchmark_timer_class timer; + Botan::AutoSeeded_RNG rng; + Botan::Algorithm_Factory& af = + Botan::global_state().algorithm_factory(); + + const int milliseconds = 5000; + + std::map results = + Botan::algorithm_benchmark("SHA-1", milliseconds, timer, rng, af); + + for(std::map::const_iterator i = results.begin(); + i != results.end(); ++i) + { + P(F("SHA-1 provider '%s': %s MiB/s") % i->first % i->second); + } + +#else int mebibytes = 100; string test_str(mebibytes << 20, 'a'); data test_data(test_str); @@ -37,6 +82,7 @@ CMD_HIDDEN(benchmark_sha1, "benchmark_sh double end = cpu_now(); double mebibytes_per_sec = mebibytes / (end - start); P(F("%s MiB/s") % mebibytes_per_sec); +#endif }