diff options
author | Jack Lloyd <[email protected]> | 2018-03-08 08:31:27 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-03-08 08:31:27 -0500 |
commit | 0138f2fca81cdf6d14b913c36f9ae1af140def81 (patch) | |
tree | 070ea19ee391caff07f76f1af421534745945100 /src | |
parent | 34aa3778a0f426fb7487c62049570d504e447c2f (diff) |
Add estimate of cycle counter rate to speed output
Diffstat (limited to 'src')
-rw-r--r-- | src/cli/speed.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/cli/speed.cpp b/src/cli/speed.cpp index 209e8d68a..729ece949 100644 --- a/src/cli/speed.cpp +++ b/src/cli/speed.cpp @@ -718,6 +718,12 @@ class Speed final : public Command } } + if(verbose() || m_summary) + { + output() << Botan::version_string() << "\n" + << "CPUID: " << Botan::CPUID::to_string() << "\n\n"; + } + const bool using_defaults = (algos.empty()); if(using_defaults) { @@ -954,20 +960,30 @@ class Speed final : public Command } if(m_summary) { - output() << m_summary->print() << "\n" - << Botan::version_string() << "\n" - << "CPUID: " << Botan::CPUID::to_string() << "\n"; + output() << m_summary->print() << "\n"; + } + + if(verbose() && m_cycles_consumed > 0 && m_ns_taken > 0) + { + const double seconds = static_cast<double>(m_ns_taken) / 1000000000; + const double Hz = static_cast<double>(m_cycles_consumed) / seconds; + const double MHz = Hz / 1000000; + output() << "\nEstimated clock speed " << MHz << " MHz\n"; } } private: double m_clock_cycle_ratio; + uint64_t m_cycles_consumed = 0; + uint64_t m_ns_taken = 0; std::unique_ptr<Summary> m_summary; std::unique_ptr<JSON_Output> m_json; void record_result(const std::unique_ptr<Timer>& t) { + m_ns_taken += t->value(); + m_cycles_consumed += t->cycles_consumed(); if(m_json) { m_json->add(*t); |