Skip to content

Commit

Permalink
Add test of scheduler overhead
Browse files Browse the repository at this point in the history
  • Loading branch information
sebmarkbage committed Jul 31, 2019
1 parent f440bfd commit 7696cdd
Showing 1 changed file with 42 additions and 2 deletions.
44 changes: 42 additions & 2 deletions fixtures/scheduler/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,23 @@ <h2>Tests:</h2>
<div id="test-9"></div>
</div>
</li>
<li>
<p>Gets more than 95% of the frame time when nothing else is using the thread.</p>
<p><b>NOTE:</b> Run this test with lots of compositor thread work such as another visible tab with video or WebGL content.</p>
<button onClick="runTestTen()">Run Test 10</button>
<div><b>Expected:</b></div>
<div id="test-10-expected">
</div>
<div> -------------------------------------------------</div>
<div> If you see the same above and below it's correct.
<div> -------------------------------------------------</div>
<div><b>Actual:</b></div>
<div id="test-10"></div>
</div>
</li>
</ol>
<script src="../../build/node_modules/react/umd/react.development.js"></script>
<script src="../../build/node_modules/scheduler/umd/scheduler.development.js"></script>
<script src="../../build/node_modules/react/umd/react.production.min.js"></script>
<script src="../../build/node_modules/scheduler/umd/scheduler.production.min.js"></script>
<script src="https://unpkg.com/babel-standalone@6/babel.js"></script>
<script type="text/babel">
const {
Expand Down Expand Up @@ -267,6 +281,11 @@ <h2>Tests:</h2>
'Using new frame time!',
'Finished!',
],
// test 10
[
'Running work for 10 seconds...',
'Ran scheduled work for >95% of the time.',
],
];
function runTestOne() {
// Test 1
Expand Down Expand Up @@ -637,6 +656,27 @@ <h2>Tests:</h2>
});
}

function runTestTen() {
clearTestResult(10);
updateTestResult(10, `Running work for 10 seconds...`);
var testStartTime = now();
var accumulatedWork = 0
function loop() {
var startTime = now();
while (!shouldYield()) {}
var endTime = now();
accumulatedWork += endTime - startTime;
var runTime = endTime - testStartTime;
if (runTime > 10000) {
updateTestResult(10, `Ran scheduled work for ${(100 * accumulatedWork / runTime).toFixed(2)}% of the time.`);
displayTestResult(10);
return;
}
scheduleCallback(NormalPriority, loop);
}
scheduleCallback(NormalPriority, loop);
}

</script type="text/babel">
</body>
</html>

0 comments on commit 7696cdd

Please sign in to comment.