File: perf-test.html

package info (click to toggle)
node-ace-code 1.40.1%2B~cs1.7.37-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 24,816 kB
  • sloc: javascript: 258,622; sh: 231; asm: 185; makefile: 130; xml: 85; jsp: 85; objc: 77; lisp: 52; cpp: 34; java: 34; tcl: 30; cobol: 30; pascal: 29; ruby: 27; vhdl: 25; fortran: 21; erlang: 17; python: 13; php: 12; perl: 11; haskell: 10; ml: 10; sql: 6; ada: 5; cs: 3
file content (160 lines) | stat: -rw-r--r-- 4,660 bytes parent folder | download | duplicates (2)
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">

<html lang="en">
<head>
    <base href="..">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Ace Profile  util</title>
    <link rel="stylesheet" href="demo/kitchen-sink/styles.css" type="text/css" media="screen" charset="utf-8">
    <link href="../doc/site/images/favicon.ico" rel="icon" type="image/x-icon">
</head>
<body>
<div style="position:absolute;height:100%;width:260px">
  <div style="position: absolute; overflow: hidden; top:20px; bottom:0">
  <div style="width: 120%; height:100%; overflow-y: scroll">

  <table>
    <tr>
      <td colspan="2">
        <label for="profile">profile</label>
        <input type="checkbox" checked id="profile"></input>
        <label for="timeout">delay</label>
        <input id="timeout" type="text" value="3" style="width:10em"></input>
      </td>
    </tr>
    <tr>
      <td colspan="2">
        <button onclick = "start(this.textContent)">scroll</button>
        <button onclick = "start(this.textContent)">select</button>
        <button onclick = "start(this.textContent)">type</button>
        <button onclick = "start(this.textContent)">selectH</button>
      </td>
    </tr>
    <tr>
      <td colspan="2">
        <button onclick = "start(this.textContent)">tokenize</button>
      </td>
    </tr>

  </table>
  <div id="optionsPanel"></div>

  </div>
  </div>
</div>
  <div id="editor-container"></div>

<!--DEVEL-->
  <script type="text/javascript">
      var require = {
          baseUrl: window.location.protocol + "//" + window.location.host + window.location.pathname.split("/").slice(0, -1).join("/"),
          paths: {
              ace: "../lib/ace"
          }
      };
  </script>
  <script src="demo/kitchen-sink/require.js" data-main="../demo/kitchen-sink/demo" type="text/javascript"></script>

  <script>
    if (!Date.now) {
        Date.now = function() { return (new Date()).getTime() };
    }


    var scrollTop, startTime;
    var timeout, speed, next
    var editor, shouldProfile;

    function start(testName) {
        editor = env.editor
        timeout = parseInt(document.getElementById("timeout").value);
        shouldProfile = document.getElementById("profile").checked;

        startTime = Date.now()
        shouldProfile && console.profile()

        speed = 10;
        next = window[testName + "Next"];

        window[testName + "Start"] && window[testName + "Start"]()
        setTimeout(next, 1);
    }
    function end(){
        shouldProfile && console.profileEnd()
        var dt = startTime - Date.now()
        console.log(dt)
        ace.cmdLine.setValue(dt+"", 1)
    }

    /*editor.renderer.scrollToY(0);
    editor.navigateFileStart(0);
    */

    var scrollNext = function() {
        var r = editor.renderer
        for (var i = speed; i--; )
            r.scrollBy(0, 1)
        if (r.scrollTop + r.layerConfig.height > r.layerConfig.maxHeight - 20)
            end()
        else
            setTimeout(next, timeout, speed++)
    }

    var selectNext = function() {
        var r = editor.renderer
        for (var i = speed; i-- > 0; )
            editor.selection.selectDown()
        editor.renderer.scrollCursorIntoView()
        if (r.scrollTop + r.layerConfig.height > r.layerConfig.maxHeight - 20)
            end()
        else
            setTimeout(next, timeout, speed+=0.1)
    }

    var selectHNext = function() {
        var r = editor.renderer
        for (var i = speed; i-- > 0; )
            editor.selection.selectRight()
        if (r.scrollTop + r.layerConfig.height > r.layerConfig.maxHeight - 20)
            end()
        else
            setTimeout(next, timeout, speed+=0.1)
    }

    var typeChars = start.toString().split("")
    var typeNext = function() {
        var r = editor.renderer
        for (var i = speed; i--; )
            editor.insert(typeChars[i % typeChars.length])
        if (speed == 100)
            end()
        else
            setTimeout(next, timeout, speed++)
    }

    var tokenizer, state, lines, chunk
    var tokenizeStart = function() {
        var b = ace.session.bgTokenizer
        state = null
        tokenizer = b.tokenizer
        lines = b.doc.getAllLines()
        chunk = 1000
    }
    
    var tokenizeNext = function() {
        var states = []
        for (var i = 0, l = lines.length; i < l; i++) {
            state = tokenizer.getLineTokens(lines[i], state).state
        }
        states.push(state)
        if (speed-- > 3)
            setTimeout(next, timeout)
        else
            end()
    }

  </script>

</body>
</html>