mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-08-12 22:42:03 -04:00
add Profiler.increment and Profiler.frame
Let profiled code track frames and arguments called by incrementing a counter for a frame id or frame id and argument. This replaces the same counting by recording the call as part of a history of calls and returns. Updating the array for all calls counted takes enough time to bias the profiled run towards less overall executions.
This commit is contained in:
parent
11b52c4e60
commit
d3ae00292f
4 changed files with 161 additions and 61 deletions
src/engine
|
@ -121,12 +121,11 @@ class Sequencer {
|
|||
if (stepThreadProfilerId === -1) {
|
||||
stepThreadProfilerId = this.runtime.profiler.idByName(stepThreadProfilerFrame);
|
||||
}
|
||||
this.runtime.profiler.start(stepThreadProfilerId);
|
||||
|
||||
// Increment the number of times stepThread is called.
|
||||
this.runtime.profiler.increment(stepThreadProfilerId);
|
||||
}
|
||||
this.stepThread(activeThread);
|
||||
if (this.runtime.profiler !== null) {
|
||||
this.runtime.profiler.stop();
|
||||
}
|
||||
activeThread.warpTimer = null;
|
||||
if (activeThread.isKilled) {
|
||||
i--; // if the thread is removed from the list (killed), do not increase index
|
||||
|
@ -203,23 +202,15 @@ class Sequencer {
|
|||
if (executeProfilerId === -1) {
|
||||
executeProfilerId = this.runtime.profiler.idByName(executeProfilerFrame);
|
||||
}
|
||||
// The method commented below has its code inlined underneath to
|
||||
// reduce the bias recorded for the profiler's calls in this
|
||||
// time sensitive stepThread method.
|
||||
//
|
||||
// this.runtime.profiler.start(executeProfilerId, null);
|
||||
this.runtime.profiler.records.push(
|
||||
this.runtime.profiler.START, executeProfilerId, null, 0);
|
||||
|
||||
// Increment the number of times execute is called.
|
||||
this.runtime.profiler.increment(executeProfilerId);
|
||||
}
|
||||
if (thread.target === null) {
|
||||
this.retireThread(thread);
|
||||
} else {
|
||||
execute(this, thread);
|
||||
}
|
||||
if (this.runtime.profiler !== null) {
|
||||
// this.runtime.profiler.stop();
|
||||
this.runtime.profiler.records.push(this.runtime.profiler.STOP, 0);
|
||||
}
|
||||
thread.blockGlowInFrame = currentBlockId;
|
||||
// If the thread has yielded or is waiting, yield to other threads.
|
||||
if (thread.status === Thread.STATUS_YIELD) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue