mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2025-04-06 12:37:33 +00:00
Tidy the test harness a little.
Signed-off-by: Adrian.Conlon <adrian.conlon@gmail.com>
This commit is contained in:
parent
8927f412d4
commit
23b5a5d579
@ -6,34 +6,34 @@ namespace EightBit {
|
||||
template<class ConfigurationT, class BoardT> class TestHarness {
|
||||
public:
|
||||
TestHarness(const ConfigurationT& configuration)
|
||||
: m_configuration(configuration),
|
||||
m_board(configuration) {
|
||||
: m_configuration(configuration),
|
||||
m_board(configuration) {
|
||||
}
|
||||
|
||||
~TestHarness() {
|
||||
auto elapsedTime = m_finishTime - m_startTime;
|
||||
auto seconds = std::chrono::duration_cast<std::chrono::seconds>(elapsedTime).count();
|
||||
|
||||
std::cout << std::endl;
|
||||
std::cout << "Cycles = " << m_totalCycles << std::endl;
|
||||
std::cout << "Seconds = " << seconds << std::endl;
|
||||
|
||||
auto cyclesPerSecond = m_totalCycles / seconds;
|
||||
std::cout.imbue(std::locale(""));
|
||||
std::cout << cyclesPerSecond << " cycles/second" << std::endl;
|
||||
|
||||
std::cout << "Cycles = " << m_totalCycles << std::endl;
|
||||
std::cout << "Seconds = " << getElapsedSeconds() << std::endl;
|
||||
|
||||
std::cout << getCyclesPerSecond() << " cycles/second" << std::endl;
|
||||
}
|
||||
|
||||
std::chrono::steady_clock::duration getElapsedTime() const {
|
||||
return m_finishTime - m_startTime;
|
||||
}
|
||||
|
||||
long long getElapsedSeconds() {
|
||||
return std::chrono::duration_cast<std::chrono::seconds>(elapsedTime).count();
|
||||
long long getElapsedSeconds() const {
|
||||
return std::chrono::duration_cast<std::chrono::seconds>(getElapsedTime()).count();
|
||||
}
|
||||
|
||||
long long getCyclesPerSecond() const {
|
||||
|
||||
return m_totalCycles / getElapsedSeconds();
|
||||
}
|
||||
|
||||
void runLoop() {
|
||||
m_startTime = std::chrono::system_clock::now();
|
||||
m_startTime = now();
|
||||
m_totalCycles = 0UL;
|
||||
|
||||
auto& cpu = m_board.getCPUMutable();
|
||||
@ -41,19 +41,22 @@ namespace EightBit {
|
||||
m_totalCycles += cpu.step();
|
||||
}
|
||||
|
||||
m_finishTime = std::chrono::system_clock::now();
|
||||
m_finishTime = now();
|
||||
}
|
||||
|
||||
void initialise() {
|
||||
m_board.initialise();
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
const ConfigurationT& m_configuration;
|
||||
BoardT m_board;
|
||||
long long m_totalCycles;
|
||||
std::chrono::system_clock::time_point m_startTime;
|
||||
std::chrono::system_clock::time_point m_finishTime;
|
||||
std::chrono::steady_clock::time_point m_startTime;
|
||||
std::chrono::steady_clock::time_point m_finishTime;
|
||||
|
||||
std::chrono::steady_clock::time_point now() {
|
||||
return std::chrono::steady_clock::now();
|
||||
}
|
||||
};
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user