Skip to content

Instantly share code, notes, and snippets.

@jareware
Last active August 29, 2015 14:00
Show Gist options
  • Save jareware/11353648 to your computer and use it in GitHub Desktop.
Save jareware/11353648 to your computer and use it in GitHub Desktop.
A test document for spreading DOM manipulation workload across browser processes.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, height=device-height" />
<title>parallel-thrash</title>
<style type="text/css">
iframe {
width: 250px;
height: 500px;
border: 1px solid grey;
float: left;
margin: 10px;
}
h1 {
display: none;
}
button {
display: none;
width: 100%;
padding: 50px;
}
</style>
</head>
<body>
<!--
This is a test document for spreading DOM manipulation workload across browser processes.
@see http://www.chromium.org/developers/design-documents/site-isolation
@see http://www.chromium.org/developers/design-documents/oop-iframes
@see http://www.chromium.org/developers/design-documents/oop-iframes/oop-iframes-rendering
In /etc/hosts:
127.0.0.1 site1.test.com site2.test.com site3.test.com
Start with:
$ /Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary --site-per-process "localhost:8000"
-->
<h1>parallel-thrash</h1>
<button>Thrash</button>
<pre></pre>
<script>
(function() {
"use strict";
function thrash() {
var times = 5000;
var i = 0;
while (i++ < times) {
var p = document.createElement('p');
var oh;
oh = document.body.offsetHeight; // triggers a forced synchronous layout
p.innerText = '#' + i + ' = ' + oh;
document.body.appendChild(p);
}
}
function setUpFrames() {
var threads = 3;
for (var j = 1; j <= threads; j++) {
var ifr = document.createElement('iframe');
ifr.setAttribute('src', 'http://site' + j + '.test.com:8000/#worker');
document.body.appendChild(ifr);
}
}
if (location.hash === '') { // master window
document.querySelector('h1').style.display = 'block';
setUpFrames();
document.querySelector('button').addEventListener('click', thrash);
} else { // worker window
document.querySelector('button').style.display = 'block';
}
})();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment