Demonstrate that setImmediate()
has a positive impact on keyboard-scrolling in Edge.
Last active
August 6, 2018 19:06
Star
You must be signed in to star a gist
Input prioritiation test - setTimeout, setImmediate, promises
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<title>Input prioritization test</title> | |
<style> | |
body { | |
max-width: 700px; | |
margin: 40px auto; | |
font-family: Helvetica, Arial, "sans-serif"; | |
} | |
p { | |
font-size: 18px; | |
} | |
button { | |
font-size: 18px; | |
margin: 5px; | |
padding: 5px; | |
} | |
#blocking { | |
position: fixed; | |
left: 10px; | |
top: 10px; | |
background: rgba(0, 0, 0, 0.7); | |
color: #fafafa; | |
font-size: 20px; | |
padding: 10px; | |
display: none; | |
z-index: 2; | |
} | |
</style> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
</head> | |
<body> | |
<h1>Input prioritization test</h1> | |
<p> | |
Test the effects of blocking script on keyboard scrolling, using various timer functions. | |
</p> | |
<button onclick="runTest(testBlocking)" type="button">Test setTimeout()</button> | |
<button onclick="runTest(testBlockingWithImmediate)" type="button">Test setImmediate() (w/ setTimeout fallback)</button> | |
<button onclick="runTest(testBlockingWithPM)" type="button">Test postMessage()</button> | |
<button onclick="runTest(testBlockingWithPromises)" type="button">Test promises</button> | |
<div id=blocking>Blocking...</div> | |
<p>riverrun, past Eve and Adam's, from swerve of shore to bend | |
of bay, brings us by a commodius vicus of recirculation back to | |
Howth Castle and Environs.</p> | |
<p><img style="float:left; margin: 10px;" width=400 src="seattle2.jpg">Sir Tristram, violer d'amores, fr'over the short sea, had passen- | |
core rearrived from North Armorica on this side the scraggy | |
isthmus of Europe Minor to wielderfight his penisolate war: nor | |
had topsawyer's rocks by the stream Oconee exaggerated themselse | |
to Laurens County's gorgios while they went doublin their mumper | |
all the time: nor avoice from afire bellowsed mishe mishe to | |
tauftauf thuartpeatrick: not yet, though venissoon after, had a | |
kidscad buttended a bland old isaac: not yet, though all's fair in | |
vanessy, were sosie sesthers wroth with twone nathandjoe. Rot a | |
peck of pa's malt had Jhem or Shen brewed by arclight and rory | |
end to the regginbrow was to be seen ringsome on the aquaface.</p> | |
<p>The fall (bababadalgharaghtakamminarronnkonnbronntonner- | |
ronntuonnthunntrovarrhounawnskawntoohoohoordenenthur- | |
nuk!) of a once wallstrait oldparr is retaled early in bed and later | |
on life down through all christian minstrelsy. The great fall of the | |
offwall entailed at such short notice the pftjschute of Finnegan, | |
erse solid man, that the humptyhillhead of humself prumptly sends | |
an unquiring one well to the west in quest of his tumptytumtoes: | |
and their upturnpikepointandplace is at the knock out in the park | |
where oranges have been laid to rust upon the green since dev- | |
linsfirst loved livvy. </p> | |
<p>What clashes here of wills gen wonts, oystrygods gaggin fishy- | |
gods! Brékkek Kékkek Kékkek Kékkek! Kóax Kóax Kóax! Ualu | |
Ualu Ualu! Quaouauh! Where the Baddelaries partisans are still | |
out to mathmaster Malachus Micgranes and the Verdons cata- | |
pelting the camibalistics out of the Whoyteboyce of Hoodie | |
Head. Assiegates and boomeringstroms. Sod's brood, be me fear! | |
Sanglorians, save! Arms apeal with larms, appalling. Killykill- | |
killy: a toll, a toll. What chance cuddleys, what cashels aired | |
and ventilated! What bidimetoloves sinduced by what tegotetab- | |
solvers! What true feeling for their's hayair with what strawng | |
voice of false jiccup! O here here how hoth sprowled met the | |
duskt the father of fornicationists but, (O my shining stars and | |
body!) how hath fanespanned most high heaven the skysign of | |
soft advertisement! But was iz? Iseut? Ere were sewers? The oaks | |
of ald now they lie in peat yet elms leap where askes lay. Phall if | |
you but will, rise you must: and none so soon either shall the | |
pharce for the nunce come to a setdown secular phoenish.</p> | |
<p>Bygmester Finnegan, of the Stuttering Hand, freemen's mau- | |
rer, lived in the broadest way immarginable in his rushlit toofar- | |
back for messuages before joshuan judges had given us numbers | |
or Helviticus committed deuteronomy (one yeastyday he sternely | |
struxk his tete in a tub for to watsch the future of his fates but ere | |
he swiftly stook it out again, by the might of moses, the very wat- | |
er was eviparated and all the guenneses had met their exodus so | |
that ought to show you what a pentschanjeuchy chap he was!) | |
and during mighty odd years this man of hod, cement and edi- | |
fices in Toper's Thorp piled buildung supra buildung pon the | |
banks for the livers by the Soangso. He addle liddle phifie Annie | |
ugged the little craythur. Wither hayre in honds tuck up your part | |
inher. Oftwhile balbulous, mithre ahead, with goodly trowel in | |
grasp and ivoroiled overalls which he habitacularly fondseed, like | |
Haroun Childeric Eggeberth he would caligulate by multiplicab- | |
les the alltitude and malltitude until he seesaw by neatlight of the | |
liquor wheretwin 'twas born, his roundhead staple of other days | |
to rise in undress maisonry upstanded (joygrantit!), a waalworth | |
of a skyerscape of most eyeful hoyth entowerly, erigenating from | |
next to nothing and celescalating the himals and all, hierarchitec- | |
titiptitoploftical, with a burning bush abob off its baubletop and | |
with larrons o'toolers clittering up and tombles a'buckets clotter- | |
ing down.</p> | |
<p><img style="float:right; margin: 10px;" width=400 src="seattle1.jpg">Of the first was he to bare arms and a name: Wassaily Boos- | |
laeugh of Riesengeborg. His crest of huroldry, in vert with | |
ancillars, troublant, argent, a hegoak, poursuivant, horrid, horned. | |
His scutschum fessed, with archers strung, helio, of the second. | |
Hootch is for husbandman handling his hoe. Hohohoho, Mister | |
Finn, you're going to be Mister Finnagain! Comeday morm and, | |
O, you're vine! Sendday's eve and, ah, you're vinegar! Hahahaha, | |
Mister Funn, you're going to be fined again!</p> | |
<p>What then agentlike brought about that tragoady thundersday | |
this municipal sin business? Our cubehouse still rocks as earwitness | |
to the thunder of his arafatas but we hear also through successive | |
ages that shebby choruysh of unkalified muzzlenimiissilehims that | |
would blackguardise the whitestone ever hurtleturtled out of | |
heaven. Stay us wherefore in our search for tighteousness, O Sus- | |
tainer, what time we rise and when we take up to toothmick and | |
before we lump down upown our leatherbed and in the night and | |
at the fading of the stars! For a nod to the nabir is better than wink | |
to the wabsanti. Otherways wesways like that provost scoffing | |
bedoueen the jebel and the jpysian sea. Cropherb the crunch- | |
bracken shall decide. Then we'll know if the feast is a flyday. She | |
has a gift of seek on site and she allcasually ansars helpers, the | |
dreamydeary. Heed! Heed! It may half been a missfired brick, as | |
some say, or it mought have been due to a collupsus of his back | |
promises, as others looked at it. (There extand by now one thou- | |
sand and one stories, all told, of the same). But so sore did abe | |
ite ivvy's holired abbles, (what with the wallhall's horrors of rolls- | |
rights, carhacks, stonengens, kisstvanes, tramtrees, fargobawlers, | |
autokinotons, hippohobbilies, streetfleets, tournintaxes, mega- | |
phoggs, circuses and wardsmoats and basilikerks and aeropagods | |
and the hoyse and the jollybrool and the peeler in the coat and | |
the mecklenburk bitch bite at his ear and the merlinburrow bur- | |
rocks and his fore old porecourts, the bore the more, and his blightblack workingstacks at twelvepins a dozen and the noobi- | |
busses sleighding along Safetyfirst Street and the derryjellybies | |
snooping around Tell-No-Tailors' Corner and the fumes and the | |
hopes and the strupithump of his ville's indigenous romekeepers, | |
homesweepers, domecreepers, thurum and thurum in fancymud | |
murumd and all the uproor from all the aufroofs, a roof for may | |
and a reef for hugh butt under his bridge suits tony) wan warn- | |
ing Phill filt tippling full. His howd feeled heavy, his hoddit did | |
shake. (There was a wall of course in erection) Dimb! He stot- | |
tered from the latter. Damb! he was dud. Dumb! Mastabatoom, | |
mastabadtomm, when a mon merries his lute is all long. For | |
whole the world to see.</p> | |
<p> <img style="float:left; margin: 10px;" width=400 src="seattle3.jpg"> Shize? I should shee! Macool, Macool, orra whyi deed ye diie? | |
of a trying thirstay mournin? Sobs they sighdid at Fillagain's | |
chrissormiss wake, all the hoolivans of the nation, prostrated in | |
their consternation and their duodisimally profusive plethora of | |
ululation. There was plumbs and grumes and cheriffs and citherers | |
and raiders and cinemen too. And the all gianed in with the shout- | |
most shoviality. Agog and magog and the round of them agrog. | |
To the continuation of that celebration until Hanandhunigan's | |
extermination! Some in kinkin corass, more, kankan keening. | |
Belling him up and filling him down. He's stiff but he's steady is | |
Priam Olim! 'Twas he was the dacent gaylabouring youth. Sharpen | |
his pillowscone, tap up his bier! E'erawhere in this whorl would ye | |
hear sich a din again? With their deepbrow fundigs and the dusty | |
fidelios. They laid him brawdawn alanglast bed. With a bockalips | |
of finisky fore his feet. And a barrowload of guenesis hoer his head. | |
Tee the tootal of the fluid hang the twoddle of the fuddled, O!</p> | |
<p>Hurrah, there is but young gleve for the owl globe wheels in | |
view which is tautaulogically the same thing. Well, Him a being | |
so on the flounder of his bulk like an overgrown babeling, let wee | |
peep, see, at Hom, well, see peegee ought he ought, platterplate. | |
Hum! From Shopalist to Bailywick or from ashtun to baronoath | |
or from Buythebanks to Roundthehead or from the foot of the | |
bill to ireglint's eye he calmly extensolies. And all the way (a | |
horn!) from fiord to fjell his baywinds' oboboes shall wail him | |
rockbound (hoahoahoah!) in swimswamswum and all the livvy- | |
long night, the delldale dalppling night, the night of bluerybells, | |
her flittaflute in tricky trochees (O carina! O carina!) wake him. | |
With her issavan essavans and her patterjackmartins about all | |
them inns and ouses. Tilling a teel of a tum, telling a toll of a tea- | |
ry turty Taubling. Grace before Glutton. For what we are, gifs | |
a gross if we are, about to believe. So pool the begg and pass the | |
kish for crawsake. Omen. So sigh us. Grampupus is fallen down | |
but grinny sprids the boord. Whase on the joint of a desh? Fin- | |
foefom the Fush. Whase be his baken head? A loaf of Singpan- | |
try's Kennedy bread. And whase hitched to the hop in his tayle? | |
A glass of Danu U'Dunnell's foamous olde Dobbelin ayle. But, | |
lo, as you would quaffoff his fraudstuff and sink teeth through | |
that pyth of a flowerwhite bodey behold of him as behemoth for | |
he is noewhemoe. Finiche! Only a fadograph of a yestern scene. | |
Almost rubicund Salmosalar, ancient fromout the ages of the Ag- | |
apemonides, he is smolten in our mist, woebecanned and packt | |
away. So that meal's dead off for summan, schlook, schlice and | |
goodridhirring.</p> | |
<script> | |
(function () { | |
var $ = document.querySelector.bind(document); | |
var immediate = window.setImmediate || window.setTimeout; | |
var COUNT = 1000; | |
var WAIT = 5; | |
function waitFor(ms) { | |
var start = Date.now(); | |
while (Date.now() < start + ms) { } | |
} | |
function testBlocking() { | |
var done = 0; | |
var checkDone = function () { | |
if (++done === COUNT) { | |
$('#blocking').style.display = 'none'; | |
} | |
} | |
for (var i = 0; i < COUNT; i++) { | |
setTimeout(function () {waitFor(WAIT); checkDone(); }, i); | |
} | |
} | |
function testBlockingWithImmediate() { | |
var done = 0; | |
var checkDone = function () { | |
if (++done === COUNT) { | |
$('#blocking').style.display = 'none'; | |
} | |
} | |
for (var i = 0; i < COUNT; i++) { | |
immediate(function () { waitFor(WAIT); checkDone(); }); | |
} | |
} | |
function testBlockingWithPM() { | |
setTimeout(function () { | |
var done = 0; | |
var checkDone = function () { | |
if (++done === COUNT) { | |
$('#blocking').style.display = 'none'; | |
removeEventListener('message', listener); | |
} | |
} | |
var listener = function () { | |
waitFor(WAIT); | |
checkDone(); | |
} | |
addEventListener('message', listener); | |
for (var i = 0; i < COUNT; i++) { | |
postMessage('', '*'); | |
} | |
}, 0); | |
} | |
function testBlockingWithPromises() { | |
var resolved = Promise.resolve(); | |
var done = 0; | |
var checkDone = function () { | |
if (++done === COUNT) { | |
$('#blocking').style.display = 'none'; | |
} | |
} | |
for (var i = 0; i < COUNT; i++) { | |
resolved.then(function () { waitFor(WAIT); checkDone(); }) | |
} | |
} | |
function runTest(cb) { | |
$('#blocking').style.display = 'block'; | |
requestAnimationFrame(function () { | |
requestAnimationFrame(cb); | |
}); | |
} | |
window.testBlocking = testBlocking; | |
window.testBlockingWithImmediate = testBlockingWithImmediate; | |
window.testBlockingWithPM = testBlockingWithPM; | |
window.testBlockingWithPromises = testBlockingWithPromises; | |
window.runTest = runTest; | |
})(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment