diff options
author | Jack Lloyd <[email protected]> | 2017-05-18 11:48:00 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-05-18 11:49:01 -0400 |
commit | 4f4250d0a8029f9954898e1b1b1908ee1ce2de30 (patch) | |
tree | ab805120ce694ffbd62115c0c205e7e7044a16a9 | |
parent | 5d5eb3c70d3e540b49c9dd22e61bbc808a9aaa62 (diff) |
Add ability to clear cpuid bits before running benchmarks.
Should be extended further, and some duplicated logic with the tests here,
but useful as is.
[ci skip]
-rw-r--r-- | src/cli/speed.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/cli/speed.cpp b/src/cli/speed.cpp index cf048e0d2..30a01a934 100644 --- a/src/cli/speed.cpp +++ b/src/cli/speed.cpp @@ -415,7 +415,7 @@ class Speed final : public Command { public: Speed() - : Command("speed --msec=300 --provider= --buf-size=4096 *algos") {} + : Command("speed --msec=300 --provider= --buf-size=4096 --clear-cpuid= *algos") {} void go() override { @@ -424,6 +424,19 @@ class Speed final : public Command const std::string provider = get_arg("provider"); std::vector<std::string> algos = get_arg_list("algos"); + + Botan::CPUID::initialize(); + + for(std::string cpuid_to_clear : Botan::split_on(get_arg("clear-cpuid"), ',')) + { +#if defined(BOTAN_TARGET_CPU_IS_X86_FAMILY) + if(cpuid_to_clear == "avx2") + Botan::CPUID::clear_cpuid_bit(Botan::CPUID::CPUID_AVX2_BIT); + else if(cpuid_to_clear == "sse2") + Botan::CPUID::clear_cpuid_bit(Botan::CPUID::CPUID_SSE2_BIT); +#endif + } + const bool using_defaults = (algos.empty()); if(using_defaults) { |