mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2024-11-12 17:04:46 +00:00
First stab at efficiency timing support for 8080 and z80 test runners.
Signed-off-by: Adrian.Conlon <adrian.conlon@gmail.com>
This commit is contained in:
parent
052df61250
commit
5a3713fc8a
@ -8,14 +8,32 @@ Game::Game(const Configuration& configuration)
|
||||
m_board(configuration) {
|
||||
}
|
||||
|
||||
Game::~Game() {
|
||||
|
||||
auto elapsedTime = m_finishTime - m_startTime;
|
||||
auto seconds = std::chrono::duration_cast<std::chrono::seconds>(elapsedTime).count();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void Game::initialise() {
|
||||
m_board.initialise();
|
||||
}
|
||||
|
||||
void Game::runLoop() {
|
||||
|
||||
m_startTime = std::chrono::system_clock::now();
|
||||
m_totalCycles = 0UL;
|
||||
|
||||
auto& cpu = m_board.getCPUMutable();
|
||||
auto cycles = 0;
|
||||
while (!cpu.isHalted()) {
|
||||
cycles = cpu.step();
|
||||
m_totalCycles += cpu.step();
|
||||
}
|
||||
|
||||
m_finishTime = std::chrono::system_clock::now();
|
||||
}
|
||||
|
@ -2,16 +2,22 @@
|
||||
|
||||
#include "Board.h"
|
||||
|
||||
#include <chrono>
|
||||
|
||||
class Configuration;
|
||||
|
||||
class Game {
|
||||
public:
|
||||
Game(const Configuration& configuration);
|
||||
~Game();
|
||||
|
||||
void runLoop();
|
||||
void initialise();
|
||||
|
||||
private:
|
||||
const Configuration& m_configuration;
|
||||
mutable Board m_board;
|
||||
Board m_board;
|
||||
long long m_totalCycles;
|
||||
std::chrono::system_clock::time_point m_startTime;
|
||||
std::chrono::system_clock::time_point m_finishTime;
|
||||
};
|
||||
|
@ -9,7 +9,11 @@
|
||||
#include <memory>
|
||||
|
||||
#include <iostream>
|
||||
#include <chrono>
|
||||
|
||||
#include <array>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#include <boost/timer/timer.hpp>
|
||||
#include <boost/chrono.hpp>
|
||||
|
@ -71,19 +71,23 @@
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IncludePath>..\inc;..\..\inc;$(IncludePath)</IncludePath>
|
||||
<IncludePath>..\inc;..\..\inc;C:\local\boost_1_64_0;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>C:\local\boost_1_64_0\lib32-msvc-14.0;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IncludePath>..\inc;..\..\inc;$(IncludePath)</IncludePath>
|
||||
<IncludePath>..\inc;..\..\inc;C:\local\boost_1_64_0;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>C:\local\boost_1_64_0\lib64-msvc-14.0;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>..\inc;..\..\inc;$(IncludePath)</IncludePath>
|
||||
<IncludePath>..\inc;..\..\inc;C:\local\boost_1_64_0;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>C:\local\boost_1_64_0\lib32-msvc-14.0;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>..\inc;..\..\inc;$(IncludePath)</IncludePath>
|
||||
<IncludePath>..\inc;..\..\inc;C:\local\boost_1_64_0;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>C:\local\boost_1_64_0\lib64-msvc-14.0;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
|
@ -3,19 +3,42 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <boost/timer/timer.hpp>
|
||||
#include <boost/chrono.hpp>
|
||||
|
||||
Game::Game(const Configuration& configuration)
|
||||
: m_configuration(configuration),
|
||||
m_board(configuration) {
|
||||
}
|
||||
|
||||
Game::~Game() {
|
||||
|
||||
auto elapsedTime = m_finishTime - m_startTime;
|
||||
auto seconds = std::chrono::duration_cast<std::chrono::seconds>(elapsedTime).count();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void Game::initialise() {
|
||||
m_board.initialise();
|
||||
}
|
||||
|
||||
void Game::runLoop() {
|
||||
|
||||
boost::timer::auto_cpu_timer cpu_timer;
|
||||
|
||||
m_startTime = std::chrono::system_clock::now();
|
||||
m_totalCycles = 0UL;
|
||||
|
||||
auto& cpu = m_board.getCPUMutable();
|
||||
auto cycles = 0;
|
||||
while (!cpu.isHalted()) {
|
||||
cycles = cpu.step();
|
||||
m_totalCycles += cpu.step();
|
||||
}
|
||||
|
||||
m_finishTime = std::chrono::system_clock::now();
|
||||
}
|
||||
|
@ -1,22 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
//#include <stdexcept>
|
||||
//#include <string>
|
||||
//#include <memory>
|
||||
//#include <map>
|
||||
|
||||
#include "Board.h"
|
||||
|
||||
#include <chrono>
|
||||
|
||||
class Configuration;
|
||||
|
||||
class Game {
|
||||
public:
|
||||
Game(const Configuration& configuration);
|
||||
~Game();
|
||||
|
||||
void runLoop();
|
||||
void initialise();
|
||||
|
||||
private:
|
||||
const Configuration& m_configuration;
|
||||
mutable Board m_board;
|
||||
Board m_board;
|
||||
long long m_totalCycles;
|
||||
std::chrono::system_clock::time_point m_startTime;
|
||||
std::chrono::system_clock::time_point m_finishTime;
|
||||
};
|
||||
|
@ -9,16 +9,11 @@
|
||||
#include <memory>
|
||||
|
||||
#include <iostream>
|
||||
#include <chrono>
|
||||
|
||||
#include <array>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
//#include <SDL.h>
|
||||
//#include <SDL_mixer.h>
|
||||
//
|
||||
//#ifdef _MSC_VER
|
||||
//#pragma comment(lib, "SDL2.lib")
|
||||
//#pragma comment(lib, "SDL2main.lib")
|
||||
//#pragma comment(lib, "SDL2_mixer.lib")
|
||||
//#endif
|
||||
#include <boost/timer/timer.hpp>
|
||||
#include <boost/chrono.hpp>
|
||||
|
@ -71,15 +71,19 @@
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<IncludePath>..\inc;..\..\inc;C:\local\boost_1_64_0;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>C:\local\boost_1_64_0\lib32-msvc-14.0;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<IncludePath>..\inc;..\..\inc;C:\local\boost_1_64_0;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>C:\local\boost_1_64_0\lib32-msvc-14.0;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<IncludePath>..\inc;..\..\inc;C:\local\boost_1_64_0;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>C:\local\boost_1_64_0\lib64-msvc-14.0;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<IncludePath>..\inc;..\..\inc;C:\local\boost_1_64_0;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>C:\local\boost_1_64_0\lib64-msvc-14.0;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
|
Loading…
Reference in New Issue
Block a user