// Specifies the pixel column where the previous UI update finished at. (current "draw cursor" position next draw will resume from)
lastUiUpdateEndX: 0,
// An array which stores samples of msec durations spent in the emscripten main loop (emscripten_set_main_loop).
// Carries # samples equal to the pixel width of the profiler display window, and old samples are erased in a rolling window fashion.
timeSpentInMainloop: [],
// Similar to 'timeSpentInMainloop', except this stores msec durations outside the emscripten main loop callback. (either idle CPU time, browser processing, or something else)
timeSpentOutsideMainloop: [],
// Specifies the sample coordinate into the timeSpentIn/OutsideMainloop arrays that is currently being populated.
currentHistogramX: 0,
// Wallclock time denoting when the currently executing main loop callback tick began.
currentFrameStartTime: 0,
// Wallclock time denoting when the previously executing main loop was finished.
previousFrameEndTime: 0,
// The total time spent in a frame can be further subdivided down into 'sections'. This array stores info structures representing each section.
sections: [],
// The 2D canvas DOM element to which the CPU profiler graph is rendered to.
canvas: null,
// The 2D drawing context on the canvas.
drawContext: null,
// How many milliseconds in total to fit vertically into the displayed CPU profiler window? Frametimes longer than this are out the graph and not visible.
verticalTimeScale: 40,
// History of wallclock times of N most recent frame times. Used to estimate current FPS.
fpsCounterTicks: [],
// When was the FPS UI display last updated?
fpsCounterLastPrint: performance.now(),
// fpsCounter() is called once per frame to record an executed frame time, and to periodically update the FPS counter display.
fpsCounter: functionfpsCounter(){
// Record the new frame time sample, and prune the history to 120 most recent frames.
// Main UI update/redraw entry point. Drawing occurs incrementally to touch as few pixels as possible and to cause the least impact to the overall performance
// while profiling.
updateUi: functionupdateUi(startX,endX){
// Poll whether user as changed the browser window, and if so, resize the profiler window and redraw it.