Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Baekalfen committed Oct 7, 2024
1 parent 2ff11af commit 23cbcfc
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
46 changes: 27 additions & 19 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,8 @@ <h2 id="kwargs">Kwargs</h2>
raise KeyError(f&#34;Unknown keyword argument: {k}&#34;)

# Performance measures
self.avg_pre = 0
self.avg_tick = 0
self.avg_post = 0
self.avg_emu = 0

# Absolute frame count of the emulation
self.frame_count = 0
Expand Down Expand Up @@ -448,9 +447,7 @@ <h2 id="kwargs">Kwargs</h2>
if self.stopped:
return False

t_start = time.perf_counter_ns()
self._handle_events(self.events)
t_pre = time.perf_counter_ns()
if not self.paused:
self.gameshark.tick()
self.__rendering(render)
Expand All @@ -477,18 +474,7 @@ <h2 id="kwargs">Kwargs</h2>
self.mb.breakpoint_singlestep = self.mb.breakpoint_singlestep_latch

self.frame_count += 1
t_tick = time.perf_counter_ns()
self._post_tick()
t_post = time.perf_counter_ns()

nsecs = t_pre - t_start
self.avg_pre = 0.9 * self.avg_pre + (0.1*nsecs/1_000_000_000)

nsecs = t_tick - t_pre
self.avg_tick = 0.9 * self.avg_tick + (0.1*nsecs/1_000_000_000)

nsecs = t_post - t_tick
self.avg_post = 0.9 * self.avg_post + (0.1*nsecs/1_000_000_000)
self._post_handle_events()

return not self.quitting

Expand Down Expand Up @@ -537,11 +523,22 @@ <h2 id="kwargs">Kwargs</h2>
False if emulation has ended otherwise True
&#34;&#34;&#34;

_count = count
running = False
t_start = time.perf_counter_ns()
while count != 0:
_render = render and count == 1 # Only render on last tick to improve performance
running = self._tick(_render)
count -= 1
t_tick = time.perf_counter_ns()
self._post_tick()
t_post = time.perf_counter_ns()

if _count &gt; 0:
nsecs = t_tick - t_start
self.avg_tick = 0.9 * (self.avg_tick / _count) + (0.1*nsecs/1_000_000_000)
nsecs = t_post - t_start
self.avg_emu = 0.9 * (self.avg_emu / _count) + (0.1*nsecs/1_000_000_000)
return running

def _handle_events(self, events):
Expand Down Expand Up @@ -608,16 +605,16 @@ <h2 id="kwargs">Kwargs</h2>
self._plugin_manager.post_tick()
self._plugin_manager.frame_limiter(self.target_emulationspeed)

def _post_handle_events(self):
# Prepare an empty list, as the API might be used to send in events between ticks
self.events = []
while self.queued_input and self.frame_count == self.queued_input[0][0]:
_, _event = heapq.heappop(self.queued_input)
self.events.append(WindowEvent(_event))

def _update_window_title(self):
avg_emu = self.avg_pre + self.avg_tick + self.avg_post
self.window_title = f&#34;CPU/frame: {(self.avg_pre + self.avg_tick) / SPF * 100:0.2f}%&#34;
self.window_title += f&#39; Emulation: x{(round(SPF / avg_emu) if avg_emu &gt; 0 else &#34;INF&#34;)}&#39;
self.window_title = f&#34;CPU/frame: {(self.avg_tick) / SPF * 100:0.2f}%&#34;
self.window_title += f&#39; Emulation: x{(round(SPF / self.avg_emu) if self.avg_emu &gt; 0 else &#34;INF&#34;)}&#39;
if self.paused:
self.window_title += &#34;[PAUSED]&#34;
self.window_title += self._plugin_manager.window_title()
Expand Down Expand Up @@ -1608,11 +1605,22 @@ <h2 id="returns">Returns</h2>
False if emulation has ended otherwise True
&#34;&#34;&#34;

_count = count
running = False
t_start = time.perf_counter_ns()
while count != 0:
_render = render and count == 1 # Only render on last tick to improve performance
running = self._tick(_render)
count -= 1
t_tick = time.perf_counter_ns()
self._post_tick()
t_post = time.perf_counter_ns()

if _count &gt; 0:
nsecs = t_tick - t_start
self.avg_tick = 0.9 * (self.avg_tick / _count) + (0.1*nsecs/1_000_000_000)
nsecs = t_post - t_start
self.avg_emu = 0.9 * (self.avg_emu / _count) + (0.1*nsecs/1_000_000_000)
return running</code></pre>
</details>
</dd>
Expand Down
2 changes: 1 addition & 1 deletion docs/utils.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ <h1 class="title">Module <code>pyboy.utils</code></h1>

__all__ = [&#34;WindowEvent&#34;, &#34;dec_to_bcd&#34;, &#34;bcd_to_dec&#34;]

STATE_VERSION = 11
STATE_VERSION = 12

##############################################################
# Buffer classes
Expand Down

0 comments on commit 23cbcfc

Please sign in to comment.