From d1cc0d71c4caf772a5b051fbba31a62a71837d94 Mon Sep 17 00:00:00 2001 From: James Tauber Date: Mon, 15 Aug 2011 09:55:04 -0400 Subject: [PATCH] calculate and output cycles per second --- applepy.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/applepy.py b/applepy.py index 6f6e69a..47dea98 100644 --- a/applepy.py +++ b/applepy.py @@ -808,6 +808,9 @@ class CPU: def run(self): update_cycle = 0 + last_update_cycle_time = time.time() + last_update_cycle_cycles = self.cycles + quit = False while not quit: self.cycles += 2 # all instructions take this as a minimum @@ -842,6 +845,9 @@ class CPU: pygame.display.flip() self.memory.update(self.cycles) update_cycle = 0 + print (self.cycles - last_update_cycle_cycles) / (time.time() - last_update_cycle_time) + last_update_cycle_time = time.time() + last_update_cycle_cycles = self.cycles def test_run(self, start, end): self.program_counter = start