datasource-perf.html revision c28f85fdfe5f4318a887f384ac1e58d40414fdba
749N/A<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
749N/A<html>
920N/A<head>
749N/A<title>DataSource Tests</title>
920N/A<script type="text/javascript" src="/build/yui/yui.js"></script>
749N/A</head>
749N/A
749N/A<body class="yui3-skin-sam">
919N/A<h1>DataSource Performance Tests</h1>
919N/A<p><select id="testSelector"></select> <input type="button" value="Run Test" id="btnRun" disabled=true></p>
919N/A
919N/A<script type="text/javascript">
919N/A(function() {
919N/A YUI({
919N/A base: "/build/",
919N/A filter: "debug",
919N/A logInclude:{"perf":true},
919N/A useConsole: true
919N/A }).use("console", "profiler", "dump", "datasource", function(Y) {
919N/A
919N/A // Set up the page
919N/A var BTNRUN = Y.get("#btnRun"),
919N/A myConsole = new Y.Console().render();
919N/A
919N/A
749N/A BTNRUN.set("disabled", false);
749N/A Y.on("click", function(e){
749N/A Y.example.Perf.run();
749N/A }, BTNRUN);
749N/A
749N/A Y.namespace("example").Perf = function() {
749N/A var selectNode = Y.get("#testSelector"),
749N/A allTests = [];
749N/A
749N/A return {
749N/A init: function() {
749N/A this.register("Test DataSource.Local", function() {
749N/A var ds = new Y.DataSource.Local({
749N/A source: ["a","b","c","d"]
749N/A }),
749N/A callback = {
749N/A success: function(o) {},
749N/A failure: function(e) {}
749N/A },
749N/A i=0;
749N/A
749N/A while(i++<100) {
749N/A ds.sendRequest(null, callback);
749N/A }
749N/A });
749N/A
749N/A },
749N/A
749N/A register: function(testName, testFn) {
920N/A var index = allTests.length;
920N/A allTests[index] = testFn;
749N/A
749N/A var optionEl = document.createElement("option");
optionEl.innerHTML = "Test " + index + ": " + testName;
selectNode.appendChild(optionEl);
},
run: function() {
var whichTest = selectNode.get("selectedIndex");
Y.log("Starting Test " + whichTest, "info", "perf");
allTests[whichTest].apply(this);
Y.log("Test " + whichTest + " completed", "info", "perf");
}
}
}();
Y.example.Perf.init();
});
})();
</script>
</body>
</html>