[pypy-svn] r56993 - in pypy/dist/pypy/lang/gameboy: . profiling
cami at codespeak.net
cami at codespeak.net
Tue Aug 5 10:30:58 CEST 2008
Author: cami
Date: Tue Aug 5 10:30:57 2008
New Revision: 56993
Added:
pypy/dist/pypy/lang/gameboy/profiling/
pypy/dist/pypy/lang/gameboy/profiling/__init__.py
pypy/dist/pypy/lang/gameboy/profiling/gameboy_profiling_implementation.py
pypy/dist/pypy/lang/gameboy/profiling/profiling_cpu.py
Modified:
pypy/dist/pypy/lang/gameboy/gameboy_implementation.py
Log:
added profiling version, which uses a logging cpu, thus allows to create histograms of the executed OP-codes
Modified: pypy/dist/pypy/lang/gameboy/gameboy_implementation.py
==============================================================================
--- pypy/dist/pypy/lang/gameboy/gameboy_implementation.py (original)
+++ pypy/dist/pypy/lang/gameboy/gameboy_implementation.py Tue Aug 5 10:30:57 2008
@@ -36,9 +36,7 @@
while isRunning and self.handle_events():
self.emulate(constants.GAMEBOY_CLOCK >> 2)
#RSDL.Delay(1)
- except Exception:
- pass
- finally:
+ except :
self.handle_execution_error()
lltype.free(self.event, flavor='raw')
RSDL.Quit()
Added: pypy/dist/pypy/lang/gameboy/profiling/__init__.py
==============================================================================
Added: pypy/dist/pypy/lang/gameboy/profiling/gameboy_profiling_implementation.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/lang/gameboy/profiling/gameboy_profiling_implementation.py Tue Aug 5 10:30:57 2008
@@ -0,0 +1,56 @@
+#!/usr/bin/env python
+from __future__ import generators
+
+from pypy.lang.gameboy.gameboy_implementation import *
+from pypy.lang.gameboy.profiling.profiling_cpu import ProfilingCPU
+from pypy.lang.gameboy.debug import debug
+from pypy.lang.gameboy.debug.debug_socket_memory import *
+
+# GAMEBOY ----------------------------------------------------------------------
+
+class GameBoyProfilingImplementation(GameBoyImplementation):
+
+ def __init__(self, cycleLimit=0):
+ GameBoy.__init__(self)
+ self.cycleLimit = cycleLimit
+ self.cpu = ProfilingCPU(self.interrupt, self, self.cycleLimit)
+
+ def handle_executed_op_code(self, is_fetch_execute=True):
+ self.process_cpu_profiling_data()
+
+ def process_cpu_profiling_data(self):
+ self.print_time_used()
+ self.print_opcode_histo()
+ self.print_fetch_exec_histo()
+
+ def print_time_used(self):
+ pass
+
+ def print_opcode_histo(self):
+ pass
+
+ def print_fetch_exec_histo(self):
+ pass
+
+
+# CUSTOM DRIVER IMPLEMENTATIONS currently not used =============================
+
+# VIDEO DRIVER -----------------------------------------------------------------
+
+class VideoDriverDebugImplementation(VideoDriverImplementation):
+ pass
+
+
+# JOYPAD DRIVER ----------------------------------------------------------------
+
+class JoypadDriverDebugImplementation(JoypadDriverImplementation):
+ pass
+
+
+# SOUND DRIVER -----------------------------------------------------------------
+
+class SoundDriverDebugImplementation(SoundDriverImplementation):
+ pass
+
+
+# ==============================================================================
Added: pypy/dist/pypy/lang/gameboy/profiling/profiling_cpu.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/lang/gameboy/profiling/profiling_cpu.py Tue Aug 5 10:30:57 2008
@@ -0,0 +1,28 @@
+
+from __future__ import generators
+from pypy.lang.gameboy.cpu import CPU
+from pypy.lang.gameboy.debug import debug
+
+
+class ProfilingCPU(CPU):
+
+
+ def __init__(self, interrupt, memory, cycle_limit):
+ CPU.__init__(interrupt, memory)
+ self.cycle_limit = 0
+ self.op_code_count = 0
+ self.fetch_exec_opcode_histo = [0]*(0xFF+1)
+ self.opcode_histo = [0]*(0xFF+1)
+
+ def fetch_execute(self):
+ CPU.fetch_execute(self)
+ self.count += 1
+ self.fetch_exec_opcode_histo[self.last_fetch_execute_op_code] += 1
+
+
+ def execute(self, opCode):
+ CPU.execute(self, opCode)
+ self.count += 1
+ self.opcode_histo[self.last_op_code] += 1
+ if self.op_code_count >= self.cycle_limit:
+ raise Exception("Maximal Cyclecount reached")
\ No newline at end of file
More information about the Pypy-commit
mailing list