Show cycles per second as MHz

Signed-off-by: Adrian.Conlon <adrian.conlon@gmail.com>
This commit is contained in:
Adrian.Conlon 2017-07-05 19:15:58 +01:00
parent 7910ada7fa
commit d4b133e9ac

View File

@ -18,7 +18,7 @@ namespace EightBit {
std::cout << "Guest cycles = " << m_totalCycles << std::endl; std::cout << "Guest cycles = " << m_totalCycles << std::endl;
std::cout << "Seconds = " << getElapsedSeconds() << std::endl; std::cout << "Seconds = " << getElapsedSeconds() << std::endl;
std::cout << getCyclesPerSecond() << " cycles/second" << std::endl; std::cout << getCyclesPerSecond() << " MHz" << std::endl;
auto elapsedHostCycles = m_finishHostCycles - m_startHostCycles; auto elapsedHostCycles = m_finishHostCycles - m_startHostCycles;
std::cout << "Host cycles = " << elapsedHostCycles << std::endl; std::cout << "Host cycles = " << elapsedHostCycles << std::endl;
@ -31,12 +31,12 @@ namespace EightBit {
return m_finishTime - m_startTime; return m_finishTime - m_startTime;
} }
long long getElapsedSeconds() const { double getElapsedSeconds() const {
return std::chrono::duration_cast<std::chrono::seconds>(getElapsedTime()).count(); return std::chrono::duration_cast<std::chrono::duration<double>>(getElapsedTime()).count();
} }
long long getCyclesPerSecond() const { double getCyclesPerSecond() const {
return m_totalCycles / getElapsedSeconds(); return (m_totalCycles / 1000000 ) / getElapsedSeconds();
} }
void runLoop() { void runLoop() {