easy-scratch/doc/scratch-vm/Profiler.html

2295 lines
88 KiB
HTML
Raw Normal View History

2025-02-12 12:27:32 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Profiler - Documentation</title>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
<script src="scripts/nav.js" defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav >
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="-_StackFrame.html">_StackFrame</a><ul class='methods'><li data-type='method'><a href="-_StackFrame.html#.create">create</a></li><li data-type='method'><a href="-_StackFrame.html#.release">release</a></li><li data-type='method'><a href="-_StackFrame.html#reset">reset</a></li><li data-type='method'><a href="-_StackFrame.html#reuse">reuse</a></li></ul></li><li><a href="BLE.html">BLE</a><ul class='methods'><li data-type='method'><a href="BLE.html#connectPeripheral">connectPeripheral</a></li><li data-type='method'><a href="BLE.html#didReceiveCall">didReceiveCall</a></li><li data-type='method'><a href="BLE.html#disconnect">disconnect</a></li><li data-type='method'><a href="BLE.html#handleDisconnectError">handleDisconnectError</a></li><li data-type='method'><a href="BLE.html#isConnected">isConnected</a></li><li data-type='method'><a href="BLE.html#read">read</a></li><li data-type='method'><a href="BLE.html#requestPeripheral">requestPeripheral</a></li><li data-type='method'><a href="BLE.html#startNotifications">startNotifications</a></li><li data-type='method'><a href="BLE.html#write">write</a></li></ul></li><li><a href="BlockCached.html">BlockCached</a></li><li><a href="Blocks.html">Blocks</a><ul class='methods'><li data-type='method'><a href="Blocks.html#_addScript">_addScript</a></li><li data-type='method'><a href="Blocks.html#_deleteScript">_deleteScript</a></li><li data-type='method'><a href="Blocks.html#_getBackdropField">_getBackdropField</a></li><li data-type='method'><a href="Blocks.html#_getBlockParams">_getBlockParams</a></li><li data-type='method'><a href="Blocks.html#_getCostumeField">_getCostumeField</a></li><li data-type='method'><a href="Blocks.html#_getCustomBlockInternal">_getCustomBlockInternal</a></li><li data-type='method'><a href="Blocks.html#_getSoundField">_getSoundField</a></li><li data-type='method'><a href="Blocks.html#_getSpriteField">_getSpriteField</a></li><li data-type='method'><a href="Blocks.html#blocklyListen">blocklyListen</a></li><li data-type='method'><a href="Blocks.html#blockToXML">blockToXML</a></li><li data-type='method'><a href="Blocks.html#changeBlock">changeBlock</a></li><li data-type='method'><a href="Blocks.html#createBlock">createBlock</a></li><li data-type='method'><a href="Blocks.html#deleteBlock">deleteBlock</a></li><li data-type='method'><a href="Blocks.html#emitProjectChanged">emitProjectChanged</a></li><li data-type='method'><a href="Blocks.html#getAllVariableAndListReferences">getAllVariableAndListReferences</a></li><li data-type='method'><a href="Blocks.html#getBlock">getBlock</a></li><li data-type='method'><a href="Blocks.html#getBranch">getBranch</a></li><li data-type='method'><a href="Blocks.html#getFields">getFields</a></li><li data-type='method'><a href="Blocks.html#getInputs">getInputs</a></li><li data-type='method'><a href="Blocks.html#getMutation">getMutation</a></li><li data-type='method'><a href="Blocks.html#getNextBlock">getNextBlock</a></li><li data-type='method'><a href="Blocks.html#getOpcode">getOpcode</a></li><li data-type='method'><a href="Blocks.html#getProcedureDefinition">getProcedureDefinition</a></li><li data-type='method'><a href="Blocks.html#getProcedureParamNamesAndIds">getProcedureParamNamesAndIds</a></li><li data-type='method'><a href="Blocks.html#getProcedureParamNamesIdsAndDefaults">getProcedureParamNamesIdsAndDefaults</a></li><li data-type='method'><a href="Blocks.html#getScripts">getScripts</a></li><li data-type='method'><a href="Blocks.html#getTopLevelScript">getTopLevelScript</a></li><li data-type='method'><a href="Blocks.html#moveBlock">moveBlock</a></li><li data-type='method'><a href="Blocks.html#mutationToXML">mutationToXML</a></li><li data-type='method'><a href="Blocks.html#resetCache">resetCache</a></li><li data-type='method'><a href="Blocks.html#runAllMonitored">runAllMonitored</a></li><li data-type='method'><a href="Blocks.html#toXML">toXML</a></li><li data-type='method'><a href="Blocks.html#updateAssetName">updateAssetName</a></li><li data-type='method'><a href
</nav>
<div id="main">
<h1 class="page-title">Profiler</h1>
<section>
<header>
<h2>
Profiler
</h2>
</header>
<article>
<div class="container-overview">
<h4 class="name" id="Profiler"><span class="type-signature"></span>new Profiler<span class="signature">(onFrame)</span><span class="type-signature"></span></h4>
<dl class="details">
</dl>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>onFrame</code></td>
<td class="type">
<span class="param-type"><a href="global.html#FrameCallback">FrameCallback</a></span>
</td>
<td class="description last"><p>a handle called for each recorded frame.
The passed frame value may not be stored as it'll be updated with later
frame information. Any information that is further stored by the handler
should make copies or reduce the information.</p></td>
</tr>
</tbody>
</table>
</div>
<h3 class="subsection-title">Members</h3>
<h4 class="name" id=".START"><span class="type-signature">(static, constant) </span>START<span class="type-signature"> :number</span></h4>
<dl class="details">
</dl>
<div class="description">
<p>A reference to the START record id constant.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">number</span>
</li>
</ul>
<h4 class="name" id=".STOP"><span class="type-signature">(static, constant) </span>STOP<span class="type-signature"> :number</span></h4>
<dl class="details">
</dl>
<div class="description">
<p>A reference to the STOP record id constant.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">number</span>
</li>
</ul>
<h4 class="name" id="_stack"><span class="type-signature"></span>_stack<span class="type-signature"> :Array.&lt;<a href="ProfilerFrame.html">ProfilerFrame</a>></span></h4>
<dl class="details">
</dl>
<div class="description">
<p>A cache of ProfilerFrames to reuse when reporting the recorded
frames in records.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">Array.&lt;<a href="ProfilerFrame.html">ProfilerFrame</a>></span>
</li>
</ul>
<h4 class="name" id="counters"><span class="type-signature"></span>counters<span class="type-signature"> :Array.&lt;<a href="ProfilerFrame.html">ProfilerFrame</a>></span></h4>
<dl class="details">
</dl>
<div class="description">
<p>An array of profiler frames separated by counter argument. Generally
for Scratch these frames are separated by block function opcode.
This tracks each time an opcode is called.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">Array.&lt;<a href="ProfilerFrame.html">ProfilerFrame</a>></span>
</li>
</ul>
<h4 class="name" id="increments"><span class="type-signature"></span>increments<span class="type-signature"> :Array.&lt;<a href="ProfilerFrame.html">ProfilerFrame</a>></span></h4>
<dl class="details">
</dl>
<div class="description">
<p>An array of frames incremented on demand instead as part of start
and stop.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">Array.&lt;<a href="ProfilerFrame.html">ProfilerFrame</a>></span>
</li>
</ul>
<h4 class="name" id="nullFrame"><span class="type-signature"></span>nullFrame<span class="type-signature"> :<a href="ProfilerFrame.html">ProfilerFrame</a></span></h4>
<dl class="details">
</dl>
<div class="description">
<p>A frame with no id or argument.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type"><a href="ProfilerFrame.html">ProfilerFrame</a></span>
</li>
</ul>
<h4 class="name" id="onFrame"><span class="type-signature"></span>onFrame<span class="type-signature"> :<a href="global.html#FrameCallback">FrameCallback</a></span></h4>
<dl class="details">
</dl>
<div class="description">
<p>A callback handle called with each decoded frame when reporting back
all the recorded times.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type"><a href="global.html#FrameCallback">FrameCallback</a></span>
</li>
</ul>
<h4 class="name" id="records"><span class="type-signature"></span>records<span class="type-signature"> :Array.&lt;*></span></h4>
<dl class="details">
</dl>
<div class="description">
<p>A series of START and STOP values followed by arguments. After
recording is complete the full set of records is reported back by
stepping through the series to connect the relative START and STOP
information.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">Array.&lt;*></span>
</li>
</ul>
<h4 class="name" id="START"><span class="type-signature">(constant) </span>START<span class="type-signature"> :number</span></h4>
<dl class="details">
</dl>
<div class="description">
<p>A reference to the START record id constant.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">number</span>
</li>
</ul>
<h4 class="name" id="STOP"><span class="type-signature">(constant) </span>STOP<span class="type-signature"> :number</span></h4>
<dl class="details">
</dl>
<div class="description">
<p>A reference to the STOP record id constant.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">number</span>
</li>
</ul>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id=".available"><span class="type-signature">(static) </span>available<span class="signature">()</span><span class="type-signature"> &rarr; {boolean}</span></h4>
<dl class="details">
</dl>
<div class="description">
<p>Profiler is only available on platforms with the Performance API.</p>
</div>
<h5>Returns:</h5>
<div class="param-desc">
<p>Can the Profiler run in this browser?</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">boolean</span>
</dd>
</dl>
<h4 class="name" id=".idByName"><span class="type-signature">(static) </span>idByName<span class="signature">(name)</span><span class="type-signature"> &rarr; {number}</span></h4>
<dl class="details">
</dl>
<div class="description">
<p>Lookup or create an id for a frame name.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>name</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>The name to return an id for.</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>The id for the passed name.</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">number</span>
</dd>
</dl>
<h4 class="name" id=".nameById"><span class="type-signature">(static) </span>nameById<span class="signature">(id)</span><span class="type-signature"> &rarr; {string}</span></h4>
<dl class="details">
</dl>
<div class="description">
<p>Reverse lookup the name from a given frame id.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>id</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The id to search for.</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>The name for the given id.</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h4 class="name" id="frame"><span class="type-signature"></span>frame<span class="signature">(id, arg)</span><span class="type-signature"> &rarr; {Object}</span></h4>
<dl class="details">
</dl>
<div class="description">
<p>Find or create a ProfilerFrame-like object whose counter can be
incremented outside of the Profiler.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>id</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The id returned by idByName for a name symbol.</p></td>
</tr>
<tr>
<td class="name"><code>arg</code></td>
<td class="type">
<span class="param-type">*</span>
</td>
<td class="description last"><p>The argument for a frame that identifies it in addition
to the id.</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>A ProfilerFrame-like whose count should be
incremented for each call.</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
</dd>
</dl>
<h4 class="name" id="idByName"><span class="type-signature"></span>idByName<span class="signature">(name)</span><span class="type-signature"> &rarr; {number}</span></h4>
<dl class="details">
</dl>
<div class="description">
<p>Lookup or create an id for a frame name.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>name</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>The name to return an id for.</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>The id for the passed name.</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">number</span>
</dd>
</dl>
<h4 class="name" id="increment"><span class="type-signature"></span>increment<span class="signature">(id)</span><span class="type-signature"></span></h4>
<dl class="details">
</dl>
<div class="description">
<p>Increment the number of times this symbol is called.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>id</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The id returned by idByName for a name symbol.</p></td>
</tr>
</tbody>
</table>
<h4 class="name" id="nameById"><span class="type-signature"></span>nameById<span class="signature">(id)</span><span class="type-signature"> &rarr; {string}</span></h4>
<dl class="details">
</dl>
<div class="description">
<p>Reverse lookup the name from a given frame id.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>id</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The id to search for.</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>The name for the given id.</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h4 class="name" id="reportFrames"><span class="type-signature"></span>reportFrames<span class="signature">()</span><span class="type-signature"></span></h4>
<dl class="details">
</dl>
<div class="description">
<p>Decode records and report all frames to <code>this.onFrame</code>.</p>
</div>
<h4 class="name" id="start"><span class="type-signature"></span>start<span class="signature">(id, arg<span class="signature-attributes">nullable</span>)</span><span class="type-signature"></span></h4>
<dl class="details">
</dl>
<div class="description">
<p>Start recording a frame of time for an id and optional argument.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>id</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>The id returned by idByName for a name symbol like
Runtime._step.</p></td>
</tr>
<tr>
<td class="name"><code>arg</code></td>
<td class="type">
<span class="param-type">*</span>
</td>
<td class="attributes">
&lt;nullable><br>
</td>
<td class="description last"><p>An arbitrary argument value to store with the frame.</p></td>
</tr>
</tbody>
</table>
<h4 class="name" id="stop"><span class="type-signature"></span>stop<span class="signature">()</span><span class="type-signature"></span></h4>
<dl class="details">
</dl>
<div class="description">
<p>Stop the current frame.</p>
</div>
</article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/polyfill.js"></script>
<script src="scripts/linenumber.js"></script>
</body>
</html>