mirror of
https://github.com/MoleskiCoder/EightBitNet.git
synced 2025-11-03 00:16:06 +00:00
Tidy up test harnesses
This commit is contained in:
@@ -14,10 +14,8 @@ namespace Intel8080.Test
|
|||||||
configuration.DebugMode = true;
|
configuration.DebugMode = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using (var harness = new TestHarness(configuration))
|
var harness = new TestHarness(configuration);
|
||||||
{
|
harness.Run();
|
||||||
harness.Run();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,24 +4,13 @@
|
|||||||
|
|
||||||
namespace Intel8080.Test
|
namespace Intel8080.Test
|
||||||
{
|
{
|
||||||
using System;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
||||||
internal class TestHarness : IDisposable
|
internal class TestHarness(Configuration configuration)
|
||||||
{
|
{
|
||||||
private readonly Stopwatch timer = new Stopwatch();
|
private readonly Stopwatch timer = new();
|
||||||
private readonly Board board;
|
private readonly Board board = new(configuration);
|
||||||
private long totalCycles = 0;
|
private long totalCycles;
|
||||||
|
|
||||||
private bool disposed = false;
|
|
||||||
|
|
||||||
public TestHarness(Configuration configuration) => this.board = new Board(configuration);
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
this.Dispose(true);
|
|
||||||
GC.SuppressFinalize(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Run()
|
public void Run()
|
||||||
{
|
{
|
||||||
@@ -37,20 +26,9 @@ namespace Intel8080.Test
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.timer.Stop();
|
this.timer.Stop();
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void Dispose(bool disposing)
|
System.Console.Out.WriteLine($"\n\nGuest cycles = {this.totalCycles}");
|
||||||
{
|
System.Console.Out.WriteLine($"Seconds = {this.timer.ElapsedMilliseconds / 1000.0}");
|
||||||
if (!this.disposed)
|
|
||||||
{
|
|
||||||
if (disposing)
|
|
||||||
{
|
|
||||||
System.Console.Out.WriteLine($"\n\nGuest cycles = {this.totalCycles}");
|
|
||||||
System.Console.Out.WriteLine($"Seconds = {this.timer.ElapsedMilliseconds / 1000.0}");
|
|
||||||
}
|
|
||||||
|
|
||||||
this.disposed = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,12 +11,10 @@ namespace M6502.Test
|
|||||||
var configuration = new Configuration();
|
var configuration = new Configuration();
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
configuration.DebugMode;
|
configuration.DebugMode = false;
|
||||||
#endif
|
#endif
|
||||||
using (var harness = new TestHarness(configuration))
|
var harness = new TestHarness(configuration);
|
||||||
{
|
harness.Run();
|
||||||
harness.Run();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,10 +14,8 @@ namespace EightBit
|
|||||||
configuration.DebugMode = true;
|
configuration.DebugMode = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using (var harness = new TestHarness(configuration))
|
var harness = new TestHarness(configuration);
|
||||||
{
|
harness.Run();
|
||||||
harness.Run();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,24 +4,13 @@
|
|||||||
|
|
||||||
namespace EightBit
|
namespace EightBit
|
||||||
{
|
{
|
||||||
using System;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
||||||
internal class TestHarness : IDisposable
|
internal sealed class TestHarness(Configuration configuration)
|
||||||
{
|
{
|
||||||
private readonly Stopwatch timer = new Stopwatch();
|
private readonly Stopwatch timer = new();
|
||||||
private readonly Board board;
|
private readonly Board board = new(configuration);
|
||||||
private long totalCycles = 0;
|
private long totalCycles;
|
||||||
|
|
||||||
private bool disposed = false;
|
|
||||||
|
|
||||||
public TestHarness(Configuration configuration) => this.board = new Board(configuration);
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
this.Dispose(true);
|
|
||||||
GC.SuppressFinalize(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Run()
|
public void Run()
|
||||||
{
|
{
|
||||||
@@ -37,20 +26,9 @@ namespace EightBit
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.timer.Stop();
|
this.timer.Stop();
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void Dispose(bool disposing)
|
System.Console.Out.WriteLine($"\n\nGuest cycles = {this.totalCycles}");
|
||||||
{
|
System.Console.Out.WriteLine($"Seconds = {this.timer.ElapsedMilliseconds / 1000.0}");
|
||||||
if (!this.disposed)
|
|
||||||
{
|
|
||||||
if (disposing)
|
|
||||||
{
|
|
||||||
System.Console.Out.WriteLine($"\n\nGuest cycles = {this.totalCycles}");
|
|
||||||
System.Console.Out.WriteLine($"Seconds = {this.timer.ElapsedMilliseconds / 1000.0}");
|
|
||||||
}
|
|
||||||
|
|
||||||
this.disposed = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user