D3 browser memory usage test
Created
September 2, 2013 14:49
-
-
Save explunit/6413685 to your computer and use it in GitHub Desktop.
D3 browser memory usage test
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> | |
<meta http-equiv="X-UA-Compatible" content="IE=9"> | |
<html> | |
<body> | |
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> | |
<script type="text/javascript"> | |
var svg = d3.select("body").append("svg").attr( {width: 800, height: 800 }); | |
var data = new Array(1000); | |
function randomizeData() { | |
for (var i = data.length - 1; i >= 0; i--) { | |
data[i] = { id: Math.random(), x: Math.random()*800, y: Math.random()*800 } | |
}; | |
} | |
function update() { | |
randomizeData(); | |
var circles = svg.selectAll("circle") | |
.data(data, function(d) { return d.id; } ); | |
circles.exit().remove(); | |
circles.enter().append("circle") | |
.attr("id", function(d) { return d.id; }) | |
.attr("cx", function(d) { return d.x; }) | |
.attr("cy", function(d) { return d.y; }) | |
.attr( { r: 5, fill: 'blue' }) | |
.on("mouseenter", function(d) { console.log('mouse enter') }); | |
} | |
setInterval(update, 1000); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks. Chrome peaks at about 45 MB running this and then sawtooths. IE11 got to 500 MB before the browser treated the site as being unresponsive.