~smagoun/whoopsie/whoopsie-lp1017637

« back to all changes in this revision

Viewing changes to backend/stats/static/js/yui/tests/datatype/tests/number-perf.html

  • Committer: Evan Dandrea
  • Date: 2012-05-09 05:53:45 UTC
  • Revision ID: evan.dandrea@canonical.com-20120509055345-z2j41tmcbf4as5uf
The backend now lives in lp:daisy and the website (errors.ubuntu.com) now lives in lp:errors.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
 
<html>
3
 
<head>
4
 
<title>DataType Tests</title>
5
 
<script type="text/javascript" src="../../../build/yui/yui.js"></script>
6
 
</head>
7
 
 
8
 
<body class="yui3-skin-sam">
9
 
<h1>DataType Performance Tests</h1>
10
 
<p><select id="testSelector"></select> <input type="button" value="Run Test" id="btnRun" disabled=true></p>
11
 
 
12
 
<script type="text/javascript">
13
 
(function() {
14
 
    YUI({
15
 
        base: "../../../build/",
16
 
        filter: "debug",
17
 
        logInclude:{"perf":true, "datatype-number":true},
18
 
        useConsole: true
19
 
    }).use("console", "profiler", "dump", "datatype", function(Y) {
20
 
        
21
 
        // Set up the page
22
 
        var BTNRUN = Y.one("#btnRun"),
23
 
            myConsole = new Y.Console().render();
24
 
            
25
 
 
26
 
        BTNRUN.set("disabled", false);
27
 
        Y.on("click", function(e){
28
 
            Y.example.Perf.run();
29
 
        }, BTNRUN);
30
 
        
31
 
        Y.namespace("example").Perf = function() {
32
 
            var selectNode = Y.one("#testSelector"),
33
 
                allTests = [];
34
 
                
35
 
            return {
36
 
                init: function() {
37
 
                    this.register("Test number parsing", function() {
38
 
                        var i = -250,
39
 
                            max = 250,
40
 
                            j=0,
41
 
                            number, string;
42
 
                        
43
 
                        for(; i<max; i++) {
44
 
                            number = Y.DataType.Number.parse(i+"");
45
 
                            string = Y.DataType.Number.format(number,
46
 
                                {prefix:"pre",decimalPlaces:2,decimalSeparator:",",thousandsSeparator:".",suffix:"post"});
47
 
                        }
48
 
                    });
49
 
 
50
 
                },
51
 
                
52
 
                register: function(testName, testFn) {
53
 
                    var index = allTests.length;
54
 
                    allTests[index] = testFn;
55
 
 
56
 
                    var optionEl = document.createElement("option");
57
 
                    optionEl.innerHTML = "Test " + index + ": " + testName;
58
 
                    selectNode.appendChild(optionEl);
59
 
                },
60
 
 
61
 
                run: function() {
62
 
                    var whichTest = selectNode.get("selectedIndex");
63
 
                    Y.log("Starting Test " + whichTest, "info", "perf");
64
 
                    allTests[whichTest].apply(this);
65
 
                    Y.log("Test " + whichTest + " completed", "info", "perf");
66
 
                }
67
 
            }
68
 
        }();
69
 
        
70
 
        Y.example.Perf.init();
71
 
    });
72
 
})();
73
 
</script>
74
 
</body>
75
 
</html>