mirror of
https://github.com/MoleskiCoder/EightBitNet.git
synced 2025-11-25 06:17:29 +00:00
Add some basic runtime timings to the 6502 TestHarness class.
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
@@ -12,8 +12,10 @@ namespace M6502.Test
|
|||||||
|
|
||||||
////configuration.DebugMode = true;
|
////configuration.DebugMode = true;
|
||||||
|
|
||||||
var harness = new TestHarness(configuration);
|
using (var harness = new TestHarness(configuration))
|
||||||
|
{
|
||||||
harness.Run();
|
harness.Run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,15 +4,29 @@
|
|||||||
|
|
||||||
namespace M6502.Test
|
namespace M6502.Test
|
||||||
{
|
{
|
||||||
internal class TestHarness
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
internal class TestHarness : IDisposable
|
||||||
{
|
{
|
||||||
private Board board;
|
private readonly Stopwatch timer = new Stopwatch();
|
||||||
|
private readonly Board board;
|
||||||
|
private long totalCycles = 0;
|
||||||
|
private long instructions = 0;
|
||||||
|
|
||||||
|
private bool disposed = false;
|
||||||
|
|
||||||
public TestHarness(Configuration configuration)
|
public TestHarness(Configuration configuration)
|
||||||
{
|
{
|
||||||
this.board = new Board(configuration);
|
this.board = new Board(configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
this.Dispose(true);
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
|
|
||||||
public void Run()
|
public void Run()
|
||||||
{
|
{
|
||||||
this.board.Initialize();
|
this.board.Initialize();
|
||||||
@@ -20,9 +34,27 @@ namespace M6502.Test
|
|||||||
|
|
||||||
var cpu = this.board.CPU;
|
var cpu = this.board.CPU;
|
||||||
|
|
||||||
|
this.timer.Start();
|
||||||
while (cpu.Powered)
|
while (cpu.Powered)
|
||||||
{
|
{
|
||||||
cpu.Step();
|
this.totalCycles += cpu.Step();
|
||||||
|
++this.instructions;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.timer.Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (!this.disposed)
|
||||||
|
{
|
||||||
|
if (disposing)
|
||||||
|
{
|
||||||
|
System.Console.Out.WriteLine($"Guest cycles = {this.totalCycles}");
|
||||||
|
System.Console.Out.WriteLine($"Seconds = {this.timer.ElapsedMilliseconds / 1000.0}");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.disposed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user