Skip to contents

RAM$debug contains a host of data from the RAM's recent gameplay, relevant to the timing and rollback systems (vignette("timing") and vignette("rollback")). This is mostly useful for internal debugging (i.e. by the package dev), especially for online play.

This function prints out some timing-related debug information.

Usage

ram.debug(RAM)

Arguments

RAM

RAM object.

RAM$debug

RAM$debug contains the following elements:

$timeFor each frame, time.sec() at the start of the frame. Useful as an x-axis for plotting other elements.
$aheadAt the end of each frame, how far ahead the RAM is from the end of this frame; (RAM$time - time.sec()). If this is negative, the RAM is lagging behind.
$input.behind For any inputs received on this frame, time between their timestamp and RAM$time
$time.tickFor each frame, time it took to run ram.tick().
$time.drawFor each frame, time it took to run render.ram().
$time.inputsFor each frame, time it took to run inputs.get() and inputs.process().
$rollbacksFor each occurrence of a rollback (ram.rollback() call), records the time.sec() at which it happened.
$framesFor each frame, the value of RAM$ticks; the current tick the RAM is at. Makes rollbacks a more obvious than buffer.
$frames.drawnRecords every frame of RAM$ticks that was drawn by render.ram(), i.e. when ahead was positive (see vignette("timing")).

Examples

if (FALSE) { # \dontrun{
#plot ram.time() over time to see rollbacks:
plot(RAM$debug$time, RAM$debug$ahead, type='l')

#compare which parts of each frame took up the most time
plot(rowSums(cbind(
  RAM$debug$time.tick,
  RAM$debug$time.inputs,
  RAM$debug$time.draw
),na.rm=TRUE), type='l', main='seconds per tick by parts')
lines(RAM$debug$time.tick, col='blue')
lines(RAM$debug$time.draw, col='red')
lines(RAM$debug$time.inputs, col='green')
legend('topleft',pch=15,pt.cex=2,legend=c('total','tick','draw','input'),title='step',col=c('black','blue','red','green'))
} # }