Skip to content

Instantly share code, notes, and snippets.

@mostlygeek
Created July 28, 2010 18:25
Show Gist options
  • Select an option

  • Save mostlygeek/495691 to your computer and use it in GitHub Desktop.

Select an option

Save mostlygeek/495691 to your computer and use it in GitHub Desktop.

Revisions

  1. mostlygeek created this gist Jul 28, 2010.
    28 changes: 28 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    <!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>