Game Debug Info
ram.debug.RdRAM$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.
Arguments
- RAM
RAM object.
RAM$debug
RAM$debug contains the following elements:
$time | For each frame, time.sec() at the start of the frame. Useful as an x-axis for plotting other elements. | |
$ahead | At 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.tick | For each frame, time it took to run ram.tick(). | |
$time.draw | For each frame, time it took to run render.ram(). | |
$time.inputs | For each frame, time it took to run inputs.get() and inputs.process(). | |
$rollbacks | For each occurrence of a rollback (ram.rollback() call), records the time.sec() at which it happened. | |
$frames | For each frame, the value of RAM$ticks; the current tick the RAM is at. Makes rollbacks a more obvious than buffer. | |
$frames.drawn | Records 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'))
} # }