diff options
author | Simon Warta <[email protected]> | 2015-08-20 19:49:31 +0200 |
---|---|---|
committer | Simon Warta <[email protected]> | 2015-08-21 00:50:28 +0200 |
commit | 5bedae43e66002aefadce0b6d43bf6791d5156ca (patch) | |
tree | 859e7915f4bbb2fa50f449e6e755856670cc8773 /src/lib | |
parent | a59f013165776fc57eb2b2bfd8aff95d536d2016 (diff) |
Refactor ./botan speed
* Add random_prime benchmark
* Add is_prime benchmark
* Respect runtime in benchmark_transform(). This sets default runtime
from 2s to 0.5s per configuration
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/misc/benchmark/benchmark.cpp | 18 | ||||
-rw-r--r-- | src/lib/utils/exceptn.h | 10 |
2 files changed, 19 insertions, 9 deletions
diff --git a/src/lib/misc/benchmark/benchmark.cpp b/src/lib/misc/benchmark/benchmark.cpp index 90d8b1aca..152b45d37 100644 --- a/src/lib/misc/benchmark/benchmark.cpp +++ b/src/lib/misc/benchmark/benchmark.cpp @@ -6,6 +6,7 @@ */ #include <botan/benchmark.h> +#include <botan/exceptn.h> #include <botan/lookup.h> #include <botan/buf_comp.h> #include <botan/cipher_mode.h> @@ -153,19 +154,18 @@ algorithm_benchmark(const std::string& name, size_t buf_size) { //Algorithm_Factory& af = global_state().algorithm_factory(); - const auto providers = get_all_providers_of(name); + const auto provider_names = get_all_providers_of(name); + if (provider_names.empty()) + throw No_Provider_Found(name); std::map<std::string, double> all_results; // provider -> ops/sec - if(!providers.empty()) - { - const std::chrono::nanoseconds ns_per_provider = milliseconds / providers.size(); + const std::chrono::nanoseconds ns_per_provider = milliseconds / provider_names.size(); - for(auto provider : providers) - { - auto results = time_algorithm_ops(name, provider, rng, ns_per_provider, buf_size); - all_results[provider] = find_first_in(results, { "", "update", "encrypt" }); - } + for(auto provider : provider_names) + { + auto results = time_algorithm_ops(name, provider, rng, ns_per_provider, buf_size); + all_results[provider] = find_first_in(results, { "", "update", "encrypt" }); } return all_results; diff --git a/src/lib/utils/exceptn.h b/src/lib/utils/exceptn.h index 7e16a5dec..eef1b4d43 100644 --- a/src/lib/utils/exceptn.h +++ b/src/lib/utils/exceptn.h @@ -113,6 +113,16 @@ struct BOTAN_DLL Algorithm_Not_Found : public Lookup_Error }; /** +* No_Provider_Found Exception +*/ +struct BOTAN_DLL No_Provider_Found : public Exception + { + No_Provider_Found(const std::string& name) : + Exception("Could not find any provider for algorithm named \"" + name + "\"") + {} + }; + +/** * Invalid_Algorithm_Name Exception */ struct BOTAN_DLL Invalid_Algorithm_Name : public Invalid_Argument |