Skip to content

Instantly share code, notes, and snippets.

@mostlygeek
Created July 28, 2010 18:25
Show Gist options
  • Save mostlygeek/495691 to your computer and use it in GitHub Desktop.
Save mostlygeek/495691 to your computer and use it in GitHub Desktop.
<!DOCTYPE html5>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Testing of Components</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script>
$(function() {
// benchmark async fetching of 10 files
for (var i=0; i < 10; i++) {
// required to do it this way otherwise closures don't work
// correctly.
(function(i) {
var start = new Date().getTime();
$.get('data.txt', function(data) {
var time = (new Date().getTime()) - start;
$('#output').append("Run: " + i + " took " + time + "ms <br/>");
});
})(i); // tada!
}
});
</script>
</head>
<body id="output">
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment