Pārlūkot izejas kodu

Stores measured times and exposes them

master
hristoterezov 9 gadus atpakaļ
vecāks
revīzija
6b267bbb5e

+ 9
- 1
JitsiConference.js Parādīt failu

822
     return data;
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
  * Sends the given feedback through CallStats if enabled.
833
  * Sends the given feedback through CallStats if enabled.
827
  *
834
  *
851
  */
858
  */
852
 function setupListeners(conference) {
859
 function setupListeners(conference) {
853
     conference.xmpp.addListener(
860
     conference.xmpp.addListener(
854
-        XMPPEvents.CALL_INCOMING, function (jingleSession, jingleOffer) {
861
+        XMPPEvents.CALL_INCOMING, function (jingleSession, jingleOffer, now) {
855
 
862
 
856
         if (conference.room.isFocus(jingleSession.peerjid)) {
863
         if (conference.room.isFocus(jingleSession.peerjid)) {
857
             // Accept incoming call
864
             // Accept incoming call
858
             conference.room.setJingleSession(jingleSession);
865
             conference.room.setJingleSession(jingleSession);
866
+            conference.room.performanceTimes["session.initiate"] = now;
859
             jingleSession.initialize(false /* initiator */, conference.room);
867
             jingleSession.initialize(false /* initiator */, conference.room);
860
             conference.rtc.onIncommingCall(jingleSession);
868
             conference.rtc.onIncommingCall(jingleSession);
861
             jingleSession.acceptOffer(jingleOffer, null,
869
             jingleSession.acceptOffer(jingleOffer, null,

+ 7
- 0
JitsiConnection.js Parādīt failu

93
     this.xmpp.removeListener(event, listener);
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
 module.exports = JitsiConnection;
103
 module.exports = JitsiConnection;

+ 7
- 4
connection_optimization/external_connect.js Parādīt failu

33
 
33
 
34
     xhttp.onreadystatechange = function() {
34
     xhttp.onreadystatechange = function() {
35
         if (xhttp.readyState == xhttp.DONE) {
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
             if (xhttp.status == HTTP_STATUS_OK) {
39
             if (xhttp.status == HTTP_STATUS_OK) {
39
                 try {
40
                 try {
40
                     var data = JSON.parse(xhttp.responseText);
41
                     var data = JSON.parse(xhttp.responseText);
52
     xhttp.timeout = 3000;
53
     xhttp.timeout = 3000;
53
 
54
 
54
     xhttp.open("GET", webserviceUrl, true);
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
     xhttp.send();
60
     xhttp.send();
58
 }
61
 }

+ 4
- 1
modules/xmpp/ChatRoom.js Parādīt failu

83
     this.lastPresences = {};
83
     this.lastPresences = {};
84
     this.phoneNumber = null;
84
     this.phoneNumber = null;
85
     this.phonePin = null;
85
     this.phonePin = null;
86
+    this.performanceTimes = {};
86
 }
87
 }
87
 
88
 
88
 ChatRoom.prototype.initPresenceMap = function () {
89
 ChatRoom.prototype.initPresenceMap = function () {
263
         }
264
         }
264
         if (!this.joined) {
265
         if (!this.joined) {
265
             this.joined = true;
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
             this.eventEmitter.emit(XMPPEvents.MUC_JOINED);
270
             this.eventEmitter.emit(XMPPEvents.MUC_JOINED);
268
         }
271
         }
269
     } else if (this.members[from] === undefined) {
272
     } else if (this.members[from] === undefined) {

+ 6
- 1
modules/xmpp/JingleSessionPC.js Parādīt failu

152
      */
152
      */
153
     this.peerconnection.oniceconnectionstatechange = function (event) {
153
     this.peerconnection.oniceconnectionstatechange = function (event) {
154
         if (!(self && self.peerconnection)) return;
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
         logger.log("(TIME) ICE " + self.peerconnection.iceConnectionState +
160
         logger.log("(TIME) ICE " + self.peerconnection.iceConnectionState +
156
-                    ":\t", window.performance.now());
161
+                    ":\t", now);
157
         self.updateModifySourcesQueue();
162
         self.updateModifySourcesQueue();
158
         switch (self.peerconnection.iceConnectionState) {
163
         switch (self.peerconnection.iceConnectionState) {
159
             case 'connected':
164
             case 'connected':

+ 3
- 4
modules/xmpp/strophe.jingle.js Parādīt failu

94
             // see http://xmpp.org/extensions/xep-0166.html#concepts-session
94
             // see http://xmpp.org/extensions/xep-0166.html#concepts-session
95
             switch (action) {
95
             switch (action) {
96
                 case 'session-initiate':
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
                     var startMuted = $(iq).find('jingle>startmuted');
99
                     var startMuted = $(iq).find('jingle>startmuted');
100
                     if (startMuted && startMuted.length > 0) {
100
                     if (startMuted && startMuted.length > 0) {
101
                         var audioMuted = startMuted.attr("audio");
101
                         var audioMuted = startMuted.attr("audio");
116
                     var jingleOffer = $(iq).find('>jingle');
116
                     var jingleOffer = $(iq).find('>jingle');
117
                     // FIXME there's no nice way with event to get the reason
117
                     // FIXME there's no nice way with event to get the reason
118
                     // why the call was rejected
118
                     // why the call was rejected
119
-                    eventEmitter.emit(XMPPEvents.CALL_INCOMING, sess, jingleOffer);
119
+                    eventEmitter.emit(XMPPEvents.CALL_INCOMING, sess, jingleOffer, now);
120
                     if (!sess.active())
120
                     if (!sess.active())
121
                     {
121
                     {
122
                         // Call not accepted
122
                         // Call not accepted
253
         }
253
         }
254
     });
254
     });
255
 };
255
 };
256
-

+ 8
- 3
modules/xmpp/xmpp.js Parādīt failu

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

Notiek ielāde…
Atcelt
Saglabāt