ScratchAddons
ScratchAddons copied to clipboard
New Addon: Timing Blocks and Line-By-Line Profiling for Debugger
Resolves #7418
Changes
This is the biggest addon I've made to date. It adds:
- two new blocks: "start timer" and "stop timer"
- the block-switching addon is modified to account for these blocks
- a new tab for debugger called "Timing"
- Timing tab use a logView to show a table of the stored timing data from the started timers
- The info shown is: Total Time, Average Time, Percent Time, Call count
- Via a setting you can replace Percent Time with Ratio time, which is the total time divided by the minimum total time
- Every logged timer has a label either with the timer name or the block name, which is clickable and takes you to the start timing/ block line.
- A "tools" button is added which when clicked shows a dropdown toolbar. The toolbar has 3 buttons:
- View Line-by-line: This triggers a custom profiler to enable itself, and begin tracking line by line times. Each line adds it's own timer
- Show RTC: this begins tracking the Relative Time Cost (RTC) for each line. Where RTC is a precomputed time cost which is derived from the total set of block used in the line. When RTC is shown a column is added displaying elapsed RTC for each column
- Show Heatmap: this recolours the block line associated with each timer, with a heatmap colour scale to visually represent the percentage time of that line.
- If heatmap is shown, then a slider appears that lets you adjust the maximum heatmap range.
- clicking the table headers sorts the column
- there is a setting which lets you automatically stop the previous timer when a start timer is called, which helps if you want to have many consecutive timers. (also cuts down on overhead)
- an export button, will export the timing table in csv format
Reason for changes
See #7418
Tests
The functionality described in Changes has been tested and works.
Remaining stuff:
- Making RTC account for blocks that are selected via dropdown
- Making RTC account for o(n) time blocks
- Make RTC account for blocks that depend on the size of the sprite
- Make RTC account for stamp blocks dependency on bitmap/vector
- Localise all the strings