aboutsummaryrefslogtreecommitdiffstats
path: root/test/e2e
diff options
context:
space:
mode:
authorJan Tuomi <jan@jantuomi.fi>2024-04-11 17:50:10 +0100
committerJan Tuomi <jan@jantuomi.fi>2024-04-11 17:50:10 +0100
commit3963742d5cc195bbbcc8081ec261b0d3e0c1d83d (patch)
tree662907306f6a0f4b60fd8f3ee67e07acad6c347d /test/e2e
parent5776a07e6a3def343996c5ec83cd69242f7ea23a (diff)
Add instr/s counter
Diffstat (limited to 'test/e2e')
-rw-r--r--test/e2e/fibo/fibo.atk168
-rw-r--r--test/e2e/fibo/test_fibo.py17
2 files changed, 22 insertions, 3 deletions
diff --git a/test/e2e/fibo/fibo.atk16 b/test/e2e/fibo/fibo.atk16
index fe38fe5..2cf3d20 100644
--- a/test/e2e/fibo/fibo.atk16
+++ b/test/e2e/fibo/fibo.atk16
@@ -2,9 +2,13 @@
; will jump to label main
@include bootstrap
+@label iters
+ 51
+
@label main
- ldi 10 RA
- calli fibo ; call fibo subroutine with parameter 10
+ ldi iters RA
+ ldr RA RA
+ calli fibo ; call fibo subroutine with parameter 1000
hlt
@label fibo ; fibo(n) subroutine
diff --git a/test/e2e/fibo/test_fibo.py b/test/e2e/fibo/test_fibo.py
index a7146fc..65af07a 100644
--- a/test/e2e/fibo/test_fibo.py
+++ b/test/e2e/fibo/test_fibo.py
@@ -1,3 +1,4 @@
+import time
from atk16_asm import assemble
from atk16_emu import Machine
from test.utils import pad_bytearray
@@ -13,7 +14,21 @@ def test_fibo():
machine = Machine()
machine.load_rom_image(rom_image)
machine.reset()
+ start = time.perf_counter_ns()
machine.run_until_halted()
+ end = time.perf_counter_ns()
machine.print_state_summary()
- assert machine.ra.value == 89
+ elapsed = end - start
+ print("Elapsed time:", elapsed, "ns")
+ steps_taken = machine.steps_taken
+
+ # VGA frequency is 25.175 MHz
+ # Divided by 16, that's 1.5734375 MHz (main clock)
+ # Instructions take 3–5 cycles, the average instruction takes around 4 cycles
+ # 1.5734375 MHz / 4 = 393359.375 Hz
+ # That is the goal instruction frequency
+ # TODO limit emulation speed to 393359.375 Hz
+ print("Instructions / second:", steps_taken / (elapsed / 1e9))
+
+ assert machine.ra.value == 41443