diff options
author | Jack Lloyd <[email protected]> | 2019-09-28 08:17:56 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2019-09-28 08:17:56 -0400 |
commit | 1dcdac4a78c1e8b266e41278cc7fe51d0f79f1ab (patch) | |
tree | cdab2a663f3223adc72c97ea03e0611b1d3c04d4 /src/cli | |
parent | 99ff5c704af5da90f3ef2b2615fbe429f3310c2a (diff) | |
parent | 57ceb45b19da1ec77262ad543be004df073c4411 (diff) |
Merge GH #2124 Add poly_dbl speed util
Diffstat (limited to 'src/cli')
-rw-r--r-- | src/cli/speed.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/cli/speed.cpp b/src/cli/speed.cpp index 090b0abb1..98a51e47a 100644 --- a/src/cli/speed.cpp +++ b/src/cli/speed.cpp @@ -81,6 +81,10 @@ #include <botan/compression.h> #endif +#if defined(BOTAN_HAS_POLY_DBL) + #include <botan/internal/poly_dbl.h> +#endif + #if defined(BOTAN_HAS_PUBLIC_KEY_CRYPTO) #include <botan/pkcs8.h> #include <botan/pubkey.h> @@ -668,6 +672,12 @@ class Speed final : public Command bench_passhash9(); } #endif +#if defined(BOTAN_HAS_POLY_DBL) + else if(algo == "poly_dbl") + { + bench_poly_dbl(msec); + } +#endif #if defined(BOTAN_HAS_DL_GROUP) else if(algo == "modexp") @@ -2111,6 +2121,26 @@ class Speed final : public Command } #endif +#if defined(BOTAN_HAS_POLY_DBL) + void bench_poly_dbl(std::chrono::milliseconds msec) + { + for(size_t sz : { 8, 16, 24, 32, 64, 128 }) + { + std::unique_ptr<Timer> be_timer = make_timer("poly_dbl_be_" + std::to_string(sz)); + std::unique_ptr<Timer> le_timer = make_timer("poly_dbl_le_" + std::to_string(sz)); + + std::vector<uint8_t> buf(sz); + rng().randomize(buf.data(), sz); + + be_timer->run_until_elapsed(msec, [&]() { Botan::poly_double_n(buf.data(), buf.data(), sz); }); + le_timer->run_until_elapsed(msec, [&]() { Botan::poly_double_n_le(buf.data(), buf.data(), sz); }); + + record_result(be_timer); + record_result(le_timer); + } + } +#endif + #if defined(BOTAN_HAS_BCRYPT) void bench_bcrypt() |