ソースを参照

Stores measured times and exposes them

master
hristoterezov 9年前
コミット
6b267bbb5e

+ 9
- 1
JitsiConference.js ファイルの表示

@@ -822,6 +822,13 @@ JitsiConference.prototype.getLogs = function () {
822 822
     return data;
823 823
 };
824 824
 
825
+/**
826
+ * Returns measured performanceTimes.
827
+ */
828
+JitsiConference.prototype.getPerformanceTimes = function () {
829
+    return this.room.performanceTimes;
830
+};
831
+
825 832
 /**
826 833
  * Sends the given feedback through CallStats if enabled.
827 834
  *
@@ -851,11 +858,12 @@ JitsiConference.prototype.isCallstatsEnabled = function () {
851 858
  */
852 859
 function setupListeners(conference) {
853 860
     conference.xmpp.addListener(
854
-        XMPPEvents.CALL_INCOMING, function (jingleSession, jingleOffer) {
861
+        XMPPEvents.CALL_INCOMING, function (jingleSession, jingleOffer, now) {
855 862
 
856 863
         if (conference.room.isFocus(jingleSession.peerjid)) {
857 864
             // Accept incoming call
858 865
             conference.room.setJingleSession(jingleSession);
866
+            conference.room.performanceTimes["session.initiate"] = now;
859 867
             jingleSession.initialize(false /* initiator */, conference.room);
860 868
             conference.rtc.onIncommingCall(jingleSession);
861 869
             jingleSession.acceptOffer(jingleOffer, null,

+ 7
- 0
JitsiConnection.js ファイルの表示

@@ -93,4 +93,11 @@ JitsiConnection.prototype.removeEventListener = function (event, listener) {
93 93
     this.xmpp.removeListener(event, listener);
94 94
 }
95 95
 
96
+/**
97
+ * Returns measured performanceTimes.
98
+ */
99
+JitsiConnection.prototype.getPerformanceTimes = function () {
100
+    return this.xmpp.performanceTimes;
101
+};
102
+
96 103
 module.exports = JitsiConnection;

+ 7
- 4
connection_optimization/external_connect.js ファイルの表示

@@ -33,8 +33,9 @@ function createConnectionExternally(webserviceUrl, success_callback,
33 33
 
34 34
     xhttp.onreadystatechange = function() {
35 35
         if (xhttp.readyState == xhttp.DONE) {
36
-            console.log("(TIME) external connect XHR done:\t",
37
-                window.performance.now());
36
+            var now = window.performanceTimes["external_connect.done"] =
37
+                window.performance.now();
38
+            console.log("(TIME) external connect XHR done:\t", now);
38 39
             if (xhttp.status == HTTP_STATUS_OK) {
39 40
                 try {
40 41
                     var data = JSON.parse(xhttp.responseText);
@@ -52,7 +53,9 @@ function createConnectionExternally(webserviceUrl, success_callback,
52 53
     xhttp.timeout = 3000;
53 54
 
54 55
     xhttp.open("GET", webserviceUrl, true);
55
-    console.log("(TIME) Sending external connect XHR:\t",
56
-        window.performance.now());
56
+    window.performanceTimes = {};
57
+    var now = window.performanceTimes["external_connect.sending"] =
58
+        window.performance.now();
59
+    console.log("(TIME) Sending external connect XHR:\t", now);
57 60
     xhttp.send();
58 61
 }

+ 4
- 1
modules/xmpp/ChatRoom.js ファイルの表示

@@ -83,6 +83,7 @@ function ChatRoom(connection, jid, password, XMPP, options, settings) {
83 83
     this.lastPresences = {};
84 84
     this.phoneNumber = null;
85 85
     this.phonePin = null;
86
+    this.performanceTimes = {};
86 87
 }
87 88
 
88 89
 ChatRoom.prototype.initPresenceMap = function () {
@@ -263,7 +264,9 @@ ChatRoom.prototype.onPresence = function (pres) {
263 264
         }
264 265
         if (!this.joined) {
265 266
             this.joined = true;
266
-            console.log("(TIME) MUC joined:\t", window.performance.now());
267
+            var now = this.performanceTimes["muc.joined"] =
268
+                window.performance.now();
269
+            console.log("(TIME) MUC joined:\t", now);
267 270
             this.eventEmitter.emit(XMPPEvents.MUC_JOINED);
268 271
         }
269 272
     } else if (this.members[from] === undefined) {

+ 6
- 1
modules/xmpp/JingleSessionPC.js ファイルの表示

@@ -152,8 +152,13 @@ JingleSessionPC.prototype.doInitialize = function () {
152 152
      */
153 153
     this.peerconnection.oniceconnectionstatechange = function (event) {
154 154
         if (!(self && self.peerconnection)) return;
155
+        self.room.performanceTimes["ice.state"] =
156
+            self.room.performanceTimes["ice.state"] || [];
157
+        var now = window.performance.now();
158
+        self.room.performanceTimes["ice.state"].push(
159
+            {state: self.peerconnection.iceConnectionState, time: now});
155 160
         logger.log("(TIME) ICE " + self.peerconnection.iceConnectionState +
156
-                    ":\t", window.performance.now());
161
+                    ":\t", now);
157 162
         self.updateModifySourcesQueue();
158 163
         switch (self.peerconnection.iceConnectionState) {
159 164
             case 'connected':

+ 3
- 4
modules/xmpp/strophe.jingle.js ファイルの表示

@@ -94,8 +94,8 @@ module.exports = function(XMPP, eventEmitter) {
94 94
             // see http://xmpp.org/extensions/xep-0166.html#concepts-session
95 95
             switch (action) {
96 96
                 case 'session-initiate':
97
-                    console.log("(TIME) received session-initiate:\t",
98
-                                window.performance.now());
97
+                    var now = window.performance.now();
98
+                    console.log("(TIME) received session-initiate:\t", now);
99 99
                     var startMuted = $(iq).find('jingle>startmuted');
100 100
                     if (startMuted && startMuted.length > 0) {
101 101
                         var audioMuted = startMuted.attr("audio");
@@ -116,7 +116,7 @@ module.exports = function(XMPP, eventEmitter) {
116 116
                     var jingleOffer = $(iq).find('>jingle');
117 117
                     // FIXME there's no nice way with event to get the reason
118 118
                     // why the call was rejected
119
-                    eventEmitter.emit(XMPPEvents.CALL_INCOMING, sess, jingleOffer);
119
+                    eventEmitter.emit(XMPPEvents.CALL_INCOMING, sess, jingleOffer, now);
120 120
                     if (!sess.active())
121 121
                     {
122 122
                         // Call not accepted
@@ -253,4 +253,3 @@ module.exports = function(XMPP, eventEmitter) {
253 253
         }
254 254
     });
255 255
 };
256
-

+ 8
- 3
modules/xmpp/xmpp.js ファイルの表示

@@ -37,7 +37,7 @@ function XMPP(options, token) {
37 37
     this.eventEmitter = new EventEmitter();
38 38
     this.connection = null;
39 39
     this.disconnectInProgress = false;
40
-
40
+    this.performanceTimes = {status: []};
41 41
     this.forceMuted = false;
42 42
     this.options = options;
43 43
     initStrophePlugins(this);
@@ -61,8 +61,12 @@ XMPP.prototype.getConnection = function () { return this.connection; };
61 61
  * @msg message
62 62
  */
63 63
 XMPP.prototype.connectionHandler = function (password, status, msg) {
64
+    var now = window.performance.now();
65
+    this.performanceTimes["status"].push(
66
+        {state: Strophe.getStatusString(status),
67
+        time: now});
64 68
     logger.log("(TIME) Strophe " + Strophe.getStatusString(status) +
65
-        (msg ? "[" + msg + "]" : "") + "\t:" + window.performance.now());
69
+        (msg ? "[" + msg + "]" : "") + ":\t", now);
66 70
     if (status === Strophe.Status.CONNECTED ||
67 71
         status === Strophe.Status.ATTACHED) {
68 72
         if (this.options.useStunTurn) {
@@ -167,7 +171,8 @@ XMPP.prototype._connect = function (jid, password) {
167 171
  * @param options {object} connecting options - rid, sid, jid and password.
168 172
  */
169 173
  XMPP.prototype.attach = function (options) {
170
-    logger.log("(TIME) Strophe Attaching\t:" + window.performance.now());
174
+    var now = this.performanceTimes["attaching"] = window.performance.now();
175
+    logger.log("(TIME) Strophe Attaching\t:" + now);
171 176
     this.connection.attach(options.jid, options.sid, parseInt(options.rid,10)+1,
172 177
         this.connectionHandler.bind(this, options.password));
173 178
 }

読み込み中…
キャンセル
保存