[Pkg-javascript-commits] [sockjs-client] 31/434: Smoke test - measure latency in long-lived connections.

Tonnerre Lombard tonnerre-guest at moszumanska.debian.org
Wed Jan 8 00:46:59 UTC 2014


This is an automated email from the git hooks/post-receive script.

tonnerre-guest pushed a commit to branch master
in repository sockjs-client.

commit 81f91d51b45f96108e18fc5b3b1c72759ceec50d
Author: Marek Majkowski <majek04 at gmail.com>
Date:   Mon Aug 1 11:43:27 2011 +0100

    Smoke test - measure latency in long-lived connections.
---
 example-latency.html | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 index.html           |  1 +
 2 files changed, 75 insertions(+)

diff --git a/example-latency.html b/example-latency.html
new file mode 100644
index 0000000..2978b7f
--- /dev/null
+++ b/example-latency.html
@@ -0,0 +1,74 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
+  <meta charset="UTF-8" />
+
+  <link href="data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQEAYAAABPYyMiAAAABmJLR0T///////8JWPfcAAAACXBIWXMAAABIAAAASABGyWs+AAAAF0lEQVRIx2NgGAWjYBSMglEwCkbBSAcACBAAAeaR9cIAAAAASUVORK5CYII=" rel="icon" type="image/x-icon" />
+
+  <script type="text/javascript" src="sockjs.js"></script>
+  <script type="text/javascript" src="static/jquery.min.js"></script>
+
+  <script type="text/javascript" src="config.js"></script>
+
+  <style type="text/css">
+      .cursor {
+        height: 30px;
+        width: 30px;
+        position: absolute;
+        border: 1px solid grey;
+      }
+
+  </style>
+
+</head>
+<body>
+
+  Latency: <code id="latency"></code><br>
+  <code id="logs" style="height:200px; overflow:auto; display: block; border: 1px grey solid;">
+  </code>
+
+<script>
+    sockjs_url += '/echo';
+
+    function log(a) {
+            if ('console' in window && 'log' in window.console) {
+                console.log(a);
+            }
+            $('#logs').append($("<code>").text(a));
+            $('#logs').append($("<br>"));
+            $('#logs').scrollTop($('#logs').scrollTop()+10000);
+      }
+
+
+    var i = 0;
+    var sjs = new SockJS(sockjs_url, ['jsonp']);
+    var payload = Array(1024).join('x');
+    function do_send(){
+        sjs.send({t: (new Date()).getTime(), payload:payload})
+    }
+    function send() {
+        i += 1;
+        if (sjs.readyState === SockJS.OPEN) {
+            if( i % 2 == 0)
+                setTimeout(do_send, 500);
+            else
+                do_send();
+        }
+    }
+    sjs.onopen = function() {
+        log('connected ' + sjs.protocol);
+        send();
+    };
+    sjs.onclose = function(e) {
+        log('disconnected ' + e);
+    };
+    sjs.onmessage = function(e) {
+        var msg = e.data;
+        var td = (new Date()).getTime() - msg.t;
+        $('#latency').text('' + td + ' ms');
+        send();
+    };
+</script>
+</body>
+</html>
diff --git a/index.html b/index.html
index f6dd088..3fc955f 100644
--- a/index.html
+++ b/index.html
@@ -12,6 +12,7 @@
   <ul>
     <li><a href="tests-qunit.html">QUnit tests</a></li>
     <li><a href="example-cursors.html">Cursors example</a></li>
+    <li><a href="example-latency.html">Latency example</a></li>
   </ul>
 </body>
 </html>

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/sockjs-client.git



More information about the Pkg-javascript-commits mailing list