summaryrefslogtreecommitdiff
path: root/swat.obsolete/apps/qooxdoo-examples/performance/TypeCheck_1.html
blob: 7ef0f0db13d25e61467c18df473f4c69719e58a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>qooxdoo &raquo; Demo</title>
  <link type="text/css" rel="stylesheet" href="../../resource/css/layout.css"/>
  <!--[if IE]>
  <link type="text/css" rel="stylesheet" href="../../resource/css/layout_ie.css"/>
  <![endif]-->
  <script type="text/javascript" src="../../script/qx.js"></script>
</head>
<body>
  <script type="text/javascript" src="../../script/layout.js"></script>

  <div id="demoDescription">
    <p>Tests for typical value checks and their performance.</p>
    <ol>
      <li>Typeof with Strings</li>
      <li>Typeof with Constants</li>
      <li>Instanceof</li>
    </ol>
  </div>

  <script type="text/javascript">
  qx.core.Init.getInstance().defineMain(function()
  {
    var STR = "string";
    var NR = "number";
    var OBJ = "object";

    var str = "Hello World"
    var nr1 = 1000;
    var nr2 = Infinity;
    var nr3 = NaN;
    var nr4 = 0.432;
    var obj1 = {};
    var obj2 = { key1 : "hello world", key2 : "hello world", key3 : "hello world" }

    function typeCheckTypeof1(vLoops)
    {
      for (var i=0; i<vLoops; i++)
      {
        typeof str === "string";
        typeof nr1 === "number";
        typeof nr2 === "number";
        typeof nr3 === "number";
        typeof nr4 === "number";
        typeof obj1 === "object";
        typeof obj2 === "object";
      }
    }

    function typeCheckTypeof2(vLoops)
    {
      for (var i=0; i<vLoops; i++)
      {
        typeof str === STR;
        typeof nr1 === NR;
        typeof nr2 === NR;
        typeof nr3 === NR;
        typeof nr4 === NR;
        typeof obj1 === OBJ;
        typeof obj2 === OBJ;
      }
    }

    function typeCheckInstanceOf(vLoops)
    {
      for (var i=0; i<vLoops; i++)
      {
        str instanceof String
        nr1 instanceof Number
        nr2 instanceof Number
        nr3 instanceof Number
        nr4 instanceof Number
        obj1 instanceof Object
        obj2 instanceof Object
      }
    }

    new qx.dev.TimeTracker(typeCheckTypeof1, typeCheckTypeof2, typeCheckInstanceOf);
  });
  </script>
</body>
</html>