-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path1111004-multi-recordings.patch
1697 lines (1611 loc) · 60.3 KB
/
1111004-multi-recordings.patch
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
From f6a68fce993359c62797cc4bb7d85de9288d7ea5 Mon Sep 17 00:00:00 2001
From: Jordan Santell <[email protected]>
Date: Mon, 12 Jan 2015 13:40:47 -0800
Subject: Bug 1111004 - New performance tool now manages multiple
recordings, and can switch between recordings while profiling. r=vp
diff --git a/browser/devtools/jar.mn b/browser/devtools/jar.mn
index 43f64f8..33e6d27 100644
--- a/browser/devtools/jar.mn
+++ b/browser/devtools/jar.mn
@@ -93,16 +93,17 @@ browser.jar:
content/browser/devtools/performance.xul (performance/performance.xul)
content/browser/devtools/performance/performance-controller.js (performance/performance-controller.js)
content/browser/devtools/performance/performance-view.js (performance/performance-view.js)
content/browser/devtools/performance/views/overview.js (performance/views/overview.js)
content/browser/devtools/performance/views/details.js (performance/views/details.js)
content/browser/devtools/performance/views/details-call-tree.js (performance/views/details-call-tree.js)
content/browser/devtools/performance/views/details-waterfall.js (performance/views/details-waterfall.js)
content/browser/devtools/performance/views/details-flamegraph.js (performance/views/details-flamegraph.js)
+ content/browser/devtools/performance/views/recordings.js (performance/views/recordings.js)
#endif
content/browser/devtools/responsivedesign/resize-commands.js (responsivedesign/resize-commands.js)
content/browser/devtools/commandline.css (commandline/commandline.css)
content/browser/devtools/commandlineoutput.xhtml (commandline/commandlineoutput.xhtml)
content/browser/devtools/commandlinetooltip.xhtml (commandline/commandlinetooltip.xhtml)
content/browser/devtools/commandline/commands-index.js (commandline/commands-index.js)
content/browser/devtools/framework/toolbox-window.xul (framework/toolbox-window.xul)
content/browser/devtools/framework/toolbox-options.xul (framework/toolbox-options.xul)
diff --git a/browser/devtools/performance/modules/recording-model.js b/browser/devtools/performance/modules/recording-model.js
new file mode 100644
index 0000000..4277cc7
--- /dev/null
+++ b/browser/devtools/performance/modules/recording-model.js
@@ -0,0 +1,248 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+const { PerformanceIO } = require("devtools/performance/io");
+
+const RECORDING_IN_PROGRESS = exports.RECORDING_IN_PROGRESS = -1;
+const RECORDING_UNAVAILABLE = exports.RECORDING_UNAVAILABLE = null;
+/**
+ * Model for a wholistic profile, containing start/stop times, profiling data, frames data,
+ * timeline (marker, tick, memory) data, and methods to start/stop recording.
+ */
+
+const RecordingModel = function (options={}) {
+ this._front = options.front;
+ this._performance = options.performance;
+ this._label = options.label || "";
+};
+
+RecordingModel.prototype = {
+ _localStartTime: RECORDING_UNAVAILABLE,
+ _startTime: RECORDING_UNAVAILABLE,
+ _endTime: RECORDING_UNAVAILABLE,
+ _markers: [],
+ _frames: [],
+ _ticks: [],
+ _memory: [],
+ _profilerData: {},
+ _label: "",
+ _imported: false,
+ _isRecording: false,
+
+ /**
+ * Loads a recording from a file.
+ *
+ * @param nsILocalFile file
+ * The file to import the data form.
+ */
+ importRecording: Task.async(function *(file) {
+ let recordingData = yield PerformanceIO.loadRecordingFromFile(file);
+
+ this._imported = true;
+ this._label = recordingData.profilerData.profilerLabel || "";
+ this._startTime = recordingData.interval.startTime;
+ this._endTime = recordingData.interval.endTime;
+ this._markers = recordingData.markers;
+ this._frames = recordingData.frames;
+ this._memory = recordingData.memory;
+ this._ticks = recordingData.ticks;
+ this._profilerData = recordingData.profilerData;
+
+ return recordingData;
+ }),
+
+ /**
+ * Saves the current recording to a file.
+ *
+ * @param nsILocalFile file
+ * The file to stream the data into.
+ */
+ exportRecording: Task.async(function *(file) {
+ let recordingData = this.getAllData();
+ yield PerformanceIO.saveRecordingToFile(recordingData, file);
+ }),
+
+ /**
+ * Starts recording with the PerformanceFront, storing the start times
+ * on the model.
+ */
+ startRecording: Task.async(function *() {
+ // Times must come from the actor in order to be self-consistent.
+ // However, we also want to update the view with the elapsed time
+ // even when the actor is not generating data. To do this we get
+ // the local time and use it to compute a reasonable elapsed time.
+ this._localStartTime = this._performance.now();
+
+ let { startTime } = yield this._front.startRecording({
+ withTicks: true,
+ withMemory: true
+ });
+ this._isRecording = true;
+
+ this._startTime = startTime;
+ this._endTime = RECORDING_IN_PROGRESS;
+ this._markers = [];
+ this._frames = [];
+ this._memory = [];
+ this._ticks = [];
+ }),
+
+ /**
+ * Stops recording with the PerformanceFront, storing the end times
+ * on the model.
+ */
+ stopRecording: Task.async(function *() {
+ let results = yield this._front.stopRecording();
+ this._isRecording = false;
+
+ // If `endTime` is not yielded from timeline actor (< Fx36), fake it.
+ if (!results.endTime) {
+ results.endTime = this._startTime + this.getLocalElapsedTime();
+ }
+
+ this._endTime = results.endTime;
+ this._profilerData = results.profilerData;
+ this._markers = this._markers.sort((a,b) => (a.start > b.start));
+
+ return results;
+ }),
+
+ /**
+ * Returns the profile's label, from `console.profile(LABEL)`.
+ */
+ getLabel: function () {
+ return this._label;
+ },
+
+ /**
+ * Gets the amount of time elapsed locally after starting a recording.
+ */
+ getLocalElapsedTime: function () {
+ return this._performance.now() - this._localStartTime;
+ },
+
+ /**
+ * Returns duration of this recording, in milliseconds.
+ */
+ getDuration: function () {
+ let { startTime, endTime } = this.getInterval();
+ return endTime - startTime;
+ },
+
+ /**
+ * Gets the time interval for the current recording.
+ * @return object
+ */
+ getInterval: function() {
+ let startTime = this._startTime;
+ let endTime = this._endTime;
+
+ // Compute an approximate ending time for the current recording. This is
+ // needed to ensure that the view updates even when new data is
+ // not being generated.
+ if (endTime == RECORDING_IN_PROGRESS) {
+ endTime = startTime + this.getLocalElapsedTime();
+ }
+
+ return { startTime, endTime };
+ },
+
+ /**
+ * Gets the accumulated markers in the current recording.
+ * @return array
+ */
+ getMarkers: function() {
+ return this._markers;
+ },
+
+ /**
+ * Gets the accumulated stack frames in the current recording.
+ * @return array
+ */
+ getFrames: function() {
+ return this._frames;
+ },
+
+ /**
+ * Gets the accumulated memory measurements in this recording.
+ * @return array
+ */
+ getMemory: function() {
+ return this._memory;
+ },
+
+ /**
+ * Gets the accumulated refresh driver ticks in this recording.
+ * @return array
+ */
+ getTicks: function() {
+ return this._ticks;
+ },
+
+ /**
+ * Gets the profiler data in this recording.
+ * @return array
+ */
+ getProfilerData: function() {
+ return this._profilerData;
+ },
+
+ /**
+ * Gets all the data in this recording.
+ */
+ getAllData: function() {
+ let interval = this.getInterval();
+ let markers = this.getMarkers();
+ let frames = this.getFrames();
+ let memory = this.getMemory();
+ let ticks = this.getTicks();
+ let profilerData = this.getProfilerData();
+ return { interval, markers, frames, memory, ticks, profilerData };
+ },
+
+ /**
+ * Returns a boolean indicating whether or not this recording model
+ * is recording.
+ */
+ isRecording: function () {
+ return this._isRecording;
+ },
+
+ /**
+ * Fired whenever the PerformanceFront emits markers, memory or ticks.
+ */
+ addTimelineData: function (eventName, ...data) {
+ // If this model isn't currently recording,
+ // ignore the timeline data.
+ if (!this.isRecording()) {
+ return;
+ }
+
+ switch (eventName) {
+ // Accumulate markers into an array.
+ case "markers":
+ let [markers] = data;
+ Array.prototype.push.apply(this._markers, markers);
+ break;
+ // Accumulate stack frames into an array.
+ case "frames":
+ let [, frames] = data;
+ Array.prototype.push.apply(this._frames, frames);
+ break;
+ // Accumulate memory measurements into an array.
+ case "memory":
+ let [delta, measurement] = data;
+ this._memory.push({ delta, value: measurement.total / 1024 / 1024 });
+ break;
+ // Save the accumulated refresh driver ticks.
+ case "ticks":
+ let [, timestamps] = data;
+ this._ticks = timestamps;
+ break;
+ }
+ }
+};
+
+exports.RecordingModel = RecordingModel;
diff --git a/browser/devtools/performance/moz.build b/browser/devtools/performance/moz.build
index e133978..666a07a 100644
--- a/browser/devtools/performance/moz.build
+++ b/browser/devtools/performance/moz.build
@@ -1,12 +1,13 @@
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
EXTRA_JS_MODULES.devtools.performance += [
'modules/front.js',
'modules/io.js',
+ 'modules/recording-model.js',
'panel.js'
]
BROWSER_CHROME_MANIFESTS += ['test/browser.ini']
diff --git a/browser/devtools/performance/performance-controller.js b/browser/devtools/performance/performance-controller.js
index f260af3..1bfe2866 100644
--- a/browser/devtools/performance/performance-controller.js
+++ b/browser/devtools/performance/performance-controller.js
@@ -36,30 +36,40 @@ devtools.lazyRequireGetter(this, "CallView",
devtools.lazyRequireGetter(this, "ThreadNode",
"devtools/profiler/tree-model", true);
devtools.lazyImporter(this, "CanvasGraphUtils",
"resource:///modules/devtools/Graphs.jsm");
devtools.lazyImporter(this, "LineGraphWidget",
"resource:///modules/devtools/Graphs.jsm");
+devtools.lazyImporter(this, "SideMenuWidget",
+ "resource:///modules/devtools/SideMenuWidget.jsm");
+
+const { RecordingModel, RECORDING_IN_PROGRESS, RECORDING_UNAVAILABLE } =
+ devtools.require("devtools/performance/recording-model");
devtools.lazyImporter(this, "FlameGraphUtils",
"resource:///modules/devtools/FlameGraph.jsm");
devtools.lazyImporter(this, "FlameGraph",
"resource:///modules/devtools/FlameGraph.jsm");
// Events emitted by various objects in the panel.
const EVENTS = {
+ // Emitted by the PerformanceController or RecordingView
+ // when a recording model is selected
+ RECORDING_SELECTED: "Performance:RecordingSelected",
+
// Emitted by the PerformanceView on record button click
UI_START_RECORDING: "Performance:UI:StartRecording",
UI_STOP_RECORDING: "Performance:UI:StopRecording",
- // Emitted by the PerformanceView on import or export button click
+ // Emitted by the PerformanceView on import button click
UI_IMPORT_RECORDING: "Performance:UI:ImportRecording",
+ // Emitted by the RecordingsView on export button click
UI_EXPORT_RECORDING: "Performance:UI:ExportRecording",
// When a recording is started or stopped via the PerformanceController
RECORDING_STARTED: "Performance:RecordingStarted",
RECORDING_STOPPED: "Performance:RecordingStopped",
// When a recording is imported or exported via the PerformanceController
RECORDING_IMPORTED: "Performance:RecordingImported",
@@ -91,21 +101,16 @@ const EVENTS = {
// Emitted by the WaterfallView when it has been rendered
WATERFALL_RENDERED: "Performance:UI:WaterfallRendered",
// Emitted by the FlameGraphView when it has been rendered
FLAMEGRAPH_RENDERED: "Performance:UI:FlameGraphRendered"
};
-// Constant defining the end time for a recording that hasn't finished
-// or is not yet available.
-const RECORDING_IN_PROGRESS = -1;
-const RECORDING_UNAVAILABLE = null;
-
/**
* The current target and the profiler connection, set by this tool's host.
*/
let gToolbox, gTarget, gFront;
/**
* Initializes the profiler controller and views.
*/
@@ -145,253 +150,228 @@ let PrefObserver = {
}
};
/**
* Functions handling target-related lifetime events and
* UI interaction.
*/
let PerformanceController = {
- /**
- * Permanent storage for the markers and the memory measurements streamed by
- * the backend, along with the start and end timestamps.
- */
- _localStartTime: RECORDING_UNAVAILABLE,
- _startTime: RECORDING_UNAVAILABLE,
- _endTime: RECORDING_UNAVAILABLE,
- _markers: [],
- _frames: [],
- _memory: [],
- _ticks: [],
- _profilerData: {},
+ _recordings: [],
+ _currentRecording: null,
/**
* Listen for events emitted by the current tab target and
* main UI events.
*/
initialize: function() {
this.startRecording = this.startRecording.bind(this);
this.stopRecording = this.stopRecording.bind(this);
this.importRecording = this.importRecording.bind(this);
this.exportRecording = this.exportRecording.bind(this);
this._onTimelineData = this._onTimelineData.bind(this);
+ this._onRecordingSelectFromView = this._onRecordingSelectFromView.bind(this);
PerformanceView.on(EVENTS.UI_START_RECORDING, this.startRecording);
PerformanceView.on(EVENTS.UI_STOP_RECORDING, this.stopRecording);
- PerformanceView.on(EVENTS.UI_EXPORT_RECORDING, this.exportRecording);
PerformanceView.on(EVENTS.UI_IMPORT_RECORDING, this.importRecording);
+ RecordingsView.on(EVENTS.UI_EXPORT_RECORDING, this.exportRecording);
+ RecordingsView.on(EVENTS.RECORDING_SELECTED, this._onRecordingSelectFromView);
gFront.on("ticks", this._onTimelineData); // framerate
gFront.on("markers", this._onTimelineData); // timeline markers
gFront.on("frames", this._onTimelineData); // stack frames
gFront.on("memory", this._onTimelineData); // timeline memory
},
/**
* Remove events handled by the PerformanceController
*/
destroy: function() {
PerformanceView.off(EVENTS.UI_START_RECORDING, this.startRecording);
PerformanceView.off(EVENTS.UI_STOP_RECORDING, this.stopRecording);
- PerformanceView.off(EVENTS.UI_EXPORT_RECORDING, this.exportRecording);
PerformanceView.off(EVENTS.UI_IMPORT_RECORDING, this.importRecording);
+ RecordingsView.off(EVENTS.UI_EXPORT_RECORDING, this.exportRecording);
+ RecordingsView.off(EVENTS.RECORDING_SELECTED, this._onRecordingSelectFromView);
gFront.off("ticks", this._onTimelineData);
gFront.off("markers", this._onTimelineData);
gFront.off("frames", this._onTimelineData);
gFront.off("memory", this._onTimelineData);
},
/**
* Starts recording with the PerformanceFront. Emits `EVENTS.RECORDING_STARTED`
* when the front has started to record.
*/
startRecording: Task.async(function *() {
- // Times must come from the actor in order to be self-consistent.
- // However, we also want to update the view with the elapsed time
- // even when the actor is not generating data. To do this we get
- // the local time and use it to compute a reasonable elapsed time.
- this._localStartTime = performance.now();
-
- let { startTime } = yield gFront.startRecording({
- withTicks: true,
- withMemory: true
- });
-
- this._startTime = startTime;
- this._endTime = RECORDING_IN_PROGRESS;
- this._markers = [];
- this._frames = [];
- this._memory = [];
- this._ticks = [];
+ let model = this.createNewRecording();
+ this.setCurrentRecording(model);
+ yield model.startRecording();
- this.emit(EVENTS.RECORDING_STARTED);
+ this.emit(EVENTS.RECORDING_STARTED, model);
}),
/**
* Stops recording with the PerformanceFront. Emits `EVENTS.RECORDING_STOPPED`
* when the front has stopped recording.
*/
stopRecording: Task.async(function *() {
- let results = yield gFront.stopRecording();
-
- // If `endTime` is not yielded from timeline actor (< Fx36), fake it.
- if (!results.endTime) {
- results.endTime = this._startTime + this.getLocalElapsedTime();
- }
-
- this._endTime = results.endTime;
- this._profilerData = results.profilerData;
- this._markers = this._markers.sort((a,b) => (a.start > b.start));
+ let recording = this._getLatest();
+ yield recording.stopRecording();
- this.emit(EVENTS.RECORDING_STOPPED);
+ this.emit(EVENTS.RECORDING_STOPPED, recording);
}),
/**
* Saves the current recording to a file.
*
+ * @param RecordingModel recording
+ * The model that holds the recording data.
* @param nsILocalFile file
* The file to stream the data into.
*/
- exportRecording: Task.async(function*(_, file) {
- let recordingData = this.getAllData();
+ exportRecording: Task.async(function*(_, recording, file) {
+ let recordingData = recording.getAllData();
yield PerformanceIO.saveRecordingToFile(recordingData, file);
this.emit(EVENTS.RECORDING_EXPORTED, recordingData);
}),
/**
- * Loads a recording from a file, replacing the current one.
- * XXX: Handle multiple recordings, bug 1111004.
+ * Loads a recording from a file, adding it to the recordings list.
*
* @param nsILocalFile file
* The file to import the data from.
*/
importRecording: Task.async(function*(_, file) {
- let recordingData = yield PerformanceIO.loadRecordingFromFile(file);
+ let model = this.createNewRecording();
+ yield model.importRecording(file);
- this._startTime = recordingData.interval.startTime;
- this._endTime = recordingData.interval.endTime;
- this._markers = recordingData.markers;
- this._frames = recordingData.frames;
- this._memory = recordingData.memory;
- this._ticks = recordingData.ticks;
- this._profilerData = recordingData.profilerData;
+ this.emit(EVENTS.RECORDING_IMPORTED, model.getAllData(), model);
+ }),
- this.emit(EVENTS.RECORDING_IMPORTED, recordingData);
+ /**
+ * Creates a new RecordingModel, fires events and stores it
+ * internally in the controller.
+ */
+ createNewRecording: function () {
+ let model = new RecordingModel({
+ front: gFront,
+ performance: performance
+ });
+ this._recordings.push(model);
+ this.emit(EVENTS.RECORDING_CREATED, model);
+ return model;
+ },
- // Flush the current recording.
- this.emit(EVENTS.RECORDING_STARTED);
- this.emit(EVENTS.RECORDING_STOPPED);
- }),
+ /**
+ * Sets the active RecordingModel to `recording`.
+ */
+ setCurrentRecording: function (recording) {
+ if (this._currentRecording !== recording) {
+ this._currentRecording = recording;
+ this.emit(EVENTS.RECORDING_SELECTED, recording);
+ }
+ },
+
+ /**
+ * Return the current active RecordingModel.
+ */
+ getCurrentRecording: function () {
+ return this._currentRecording;
+ },
/**
* Gets the amount of time elapsed locally after starting a recording.
*/
- getLocalElapsedTime: function() {
- return performance.now() - this._localStartTime;
+ getLocalElapsedTime: function () {
+ return this.getCurrentRecording().getLocalElapsedTime;
},
/**
* Gets the time interval for the current recording.
* @return object
*/
getInterval: function() {
- let startTime = this._startTime;
- let endTime = this._endTime;
-
- // Compute an approximate ending time for the current recording. This is
- // needed to ensure that the view updates even when new data is
- // not being generated.
- if (endTime == RECORDING_IN_PROGRESS) {
- endTime = startTime + this.getLocalElapsedTime();
- }
-
- return { startTime, endTime };
+ return this.getCurrentRecording().getInterval();
},
/**
* Gets the accumulated markers in the current recording.
* @return array
*/
getMarkers: function() {
- return this._markers;
+ return this.getCurrentRecording().getMarkers();
},
/**
* Gets the accumulated stack frames in the current recording.
* @return array
*/
getFrames: function() {
- return this._frames;
+ return this.getCurrentRecording().getFrames();
},
/**
* Gets the accumulated memory measurements in this recording.
* @return array
*/
getMemory: function() {
- return this._memory;
+ return this.getCurrentRecording().getMemory();
},
/**
* Gets the accumulated refresh driver ticks in this recording.
* @return array
*/
getTicks: function() {
- return this._ticks;
+ return this.getCurrentRecording().getTicks();
},
/**
* Gets the profiler data in this recording.
* @return array
*/
getProfilerData: function() {
- return this._profilerData;
+ return this.getCurrentRecording().getProfilerData();
},
/**
* Gets all the data in this recording.
*/
getAllData: function() {
- let interval = this.getInterval();
- let markers = this.getMarkers();
- let frames = this.getFrames();
- let memory = this.getMemory();
- let ticks = this.getTicks();
- let profilerData = this.getProfilerData();
- return { interval, markers, frames, memory, ticks, profilerData };
+ return this.getCurrentRecording().getAllData();
},
/**
- * Fired whenever the PerformanceFront emits markers, memory or ticks.
+ /**
+ * Get most recently added profile that was triggered manually (via UI)
*/
- _onTimelineData: function (eventName, ...data) {
- // Accumulate markers into an array.
- if (eventName == "markers") {
- let [markers] = data;
- Array.prototype.push.apply(this._markers, markers);
- }
- // Accumulate stack frames into an array.
- else if (eventName == "frames") {
- let [delta, frames] = data;
- Array.prototype.push.apply(this._frames, frames);
- }
- // Accumulate memory measurements into an array.
- else if (eventName == "memory") {
- let [delta, measurement] = data;
- this._memory.push({ delta, value: measurement.total / 1024 / 1024 });
- }
- // Save the accumulated refresh driver ticks.
- else if (eventName == "ticks") {
- let [delta, timestamps] = data;
- this._ticks = timestamps;
+ _getLatest: function () {
+ for (let i = this._recordings.length - 1; i >= 0; i--) {
+ return this._recordings[i];
}
+ return null;
+ },
- this.emit(EVENTS.TIMELINE_DATA, eventName, ...data);
+ /**
+ * Fired whenever the PerformanceFront emits markers, memory or ticks.
+ */
+ _onTimelineData: function (...data) {
+ this._recordings.forEach(profile => profile.addTimelineData.apply(profile, data));
+ this.emit(EVENTS.TIMELINE_DATA, ...data);
+ },
+
+ /**
+ * Fired from RecordingsView, we listen on the PerformanceController
+ * so we can set it here and re-emit on the controller, where all views can listen.
+ */
+ _onRecordingSelectFromView: function (_, recording) {
+ this.setCurrentRecording(recording);
}
};
/**
* Convenient way of emitting events from the controller.
*/
EventEmitter.decorate(PerformanceController);
diff --git a/browser/devtools/performance/performance-view.js b/browser/devtools/performance/performance-view.js
index 7a1d5cc..900c31e 100644
--- a/browser/devtools/performance/performance-view.js
+++ b/browser/devtools/performance/performance-view.js
@@ -8,50 +8,48 @@
*/
let PerformanceView = {
/**
* Sets up the view with event binding and main subviews.
*/
initialize: function () {
this._recordButton = $("#record-button");
this._importButton = $("#import-button");
- this._exportButton = $("#export-button");
this._onRecordButtonClick = this._onRecordButtonClick.bind(this);
this._onImportButtonClick = this._onImportButtonClick.bind(this);
- this._onExportButtonClick = this._onExportButtonClick.bind(this);
this._lockRecordButton = this._lockRecordButton.bind(this);
this._unlockRecordButton = this._unlockRecordButton.bind(this);
this._recordButton.addEventListener("click", this._onRecordButtonClick);
this._importButton.addEventListener("click", this._onImportButtonClick);
- this._exportButton.addEventListener("click", this._onExportButtonClick);
// Bind to controller events to unlock the record button
PerformanceController.on(EVENTS.RECORDING_STARTED, this._unlockRecordButton);
PerformanceController.on(EVENTS.RECORDING_STOPPED, this._unlockRecordButton);
return promise.all([
+ RecordingsView.initialize(),
OverviewView.initialize(),
DetailsView.initialize()
]);
},
/**
* Unbinds events and destroys subviews.
*/
destroy: function () {
this._recordButton.removeEventListener("click", this._onRecordButtonClick);
this._importButton.removeEventListener("click", this._onImportButtonClick);
- this._exportButton.removeEventListener("click", this._onExportButtonClick);
PerformanceController.off(EVENTS.RECORDING_STARTED, this._unlockRecordButton);
PerformanceController.off(EVENTS.RECORDING_STOPPED, this._unlockRecordButton);
return promise.all([
+ RecordingsView.destroy(),
OverviewView.destroy(),
DetailsView.destroy()
]);
},
/**
* Adds the `locked` attribute on the record button. This prevents it
* from being clicked while recording is started or stopped.
@@ -89,32 +87,15 @@ let PerformanceView = {
let fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
fp.init(window, L10N.getStr("recordingsList.saveDialogTitle"), Ci.nsIFilePicker.modeOpen);
fp.appendFilter(L10N.getStr("recordingsList.saveDialogJSONFilter"), "*.json");
fp.appendFilter(L10N.getStr("recordingsList.saveDialogAllFilter"), "*.*");
if (fp.show() == Ci.nsIFilePicker.returnOK) {
this.emit(EVENTS.UI_IMPORT_RECORDING, fp.file);
}
- },
-
- /**
- * Handler for clicking the export button.
- */
- _onExportButtonClick: function(e) {
- let fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
- fp.init(window, L10N.getStr("recordingsList.saveDialogTitle"), Ci.nsIFilePicker.modeSave);
- fp.appendFilter(L10N.getStr("recordingsList.saveDialogJSONFilter"), "*.json");
- fp.appendFilter(L10N.getStr("recordingsList.saveDialogAllFilter"), "*.*");
- fp.defaultString = "profile.json";
-
- fp.open({ done: result => {
- if (result != Ci.nsIFilePicker.returnCancel) {
- this.emit(EVENTS.UI_EXPORT_RECORDING, fp.file);
- }
- }});
}
};
/**
* Convenient way of emitting events from the view.
*/
EventEmitter.decorate(PerformanceView);
diff --git a/browser/devtools/performance/performance.xul b/browser/devtools/performance/performance.xul
index 0b1f505..39fc2fe 100644
--- a/browser/devtools/performance/performance.xul
+++ b/browser/devtools/performance/performance.xul
@@ -11,98 +11,101 @@
<!ENTITY % profilerDTD SYSTEM "chrome://browser/locale/devtools/profiler.dtd">
%profilerDTD;
]>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script src="chrome://browser/content/devtools/theme-switching.js"/>
<script type="application/javascript" src="performance/performance-controller.js"/>
<script type="application/javascript" src="performance/performance-view.js"/>
+ <script type="application/javascript" src="performance/recording-model.js"/>
<script type="application/javascript" src="performance/views/overview.js"/>
<script type="application/javascript" src="performance/views/details.js"/>
<script type="application/javascript" src="performance/views/details-call-tree.js"/>
<script type="application/javascript" src="performance/views/details-waterfall.js"/>
<script type="application/javascript" src="performance/views/details-flamegraph.js"/>
+ <script type="application/javascript" src="performance/views/recordings.js"/>
- <vbox class="theme-body" flex="1">
- <toolbar id="performance-toolbar" class="devtools-toolbar">
- <hbox id="performance-toolbar-controls-recordings" class="devtools-toolbarbutton-group">
- <toolbarbutton id="record-button"
- class="devtools-toolbarbutton"
- tooltiptext="&profilerUI.recordButton.tooltip;"/>
- </hbox>
- <hbox id="performance-toolbar-controls-detail-views" class="devtools-toolbarbutton-group">
- <toolbarbutton id="select-waterfall-view"
- class="devtools-toolbarbutton"
- data-view="waterfall" />
- <toolbarbutton id="select-calltree-view"
- class="devtools-toolbarbutton"
- data-view="calltree" />
- <toolbarbutton id="select-flamegraph-view"
- class="devtools-toolbarbutton"
- data-view="flamegraph" />
- </hbox>
- <spacer flex="1"></spacer>
- <hbox id="performance-toolbar-controls-storage" class="devtools-toolbarbutton-group">
- <toolbarbutton id="import-button"
- class="devtools-toolbarbutton"
- label="&profilerUI.importButton;"/>
- <toolbarbutton id="export-button"
- class="devtools-toolbarbutton"
- label="&profilerUI.exportButton;"/>
- <toolbarbutton id="clear-button"
- class="devtools-toolbarbutton"
- label="&profilerUI.clearButton;"/>
- </hbox>
- </toolbar>
-
- <vbox id="overview-pane">
- <hbox id="markers-overview"/>
- <hbox id="memory-overview"/>
- <hbox id="time-framerate"/>
+ <hbox class="theme-body" flex="1">
+ <vbox id="recordings-pane">
+ <toolbar id="recordings-toolbar"
+ class="devtools-toolbar">
+ <hbox id="recordings-controls"
+ class="devtools-toolbarbutton-group">
+ <toolbarbutton id="record-button"
+ class="devtools-toolbarbutton"
+ tooltiptext="&profilerUI.recordButton.tooltip;"/>
+ <toolbarbutton id="import-button"
+ class="devtools-toolbarbutton"
+ label="&profilerUI.importButton;"/>
+ <toolbarbutton id="clear-button"
+ class="devtools-toolbarbutton"
+ label="&profilerUI.clearButton;"/>
+ </hbox>
+ </toolbar>
+ <vbox id="recordings-list" flex="1"/>
</vbox>
-
- <deck id="details-pane" flex="1">
-
- <hbox id="waterfall-view" flex="1">
- <vbox id="waterfall-breakdown" flex="1" />
- <splitter class="devtools-side-splitter"/>
- <vbox id="waterfall-details"
- class="theme-sidebar"
- width="150"
- height="150"/>
- </hbox>
-
- <vbox id="calltree-view" flex="1">
- <hbox class="call-tree-headers-container">
- <label class="plain call-tree-header"
- type="duration"
- crop="end"
- value="&profilerUI.table.totalDuration;"/>
- <label class="plain call-tree-header"
- type="percentage"
- crop="end"
- value="&profilerUI.table.totalPercentage;"/>
- <label class="plain call-tree-header"
- type="self-duration"
- crop="end"
- value="&profilerUI.table.selfDuration;"/>
- <label class="plain call-tree-header"
- type="self-percentage"
- crop="end"
- value="&profilerUI.table.selfPercentage;"/>
- <label class="plain call-tree-header"
- type="samples"
- crop="end"
- value="&profilerUI.table.samples;"/>
- <label class="plain call-tree-header"
- type="function"
- crop="end"
- value="&profilerUI.table.function;"/>
+ <vbox flex="1">
+ <toolbar id="performance-toolbar" class="devtools-toolbar">
+ <hbox id="performance-toolbar-controls-detail-views" class="devtools-toolbarbutton-group">
+ <toolbarbutton id="select-waterfall-view"
+ class="devtools-toolbarbutton"
+ data-view="waterfall" />
+ <toolbarbutton id="select-calltree-view"
+ class="devtools-toolbarbutton"
+ data-view="calltree" />
+ <toolbarbutton id="select-flamegraph-view"
+ class="devtools-toolbarbutton"
+ data-view="flamegraph" />
</hbox>
- <vbox class="call-tree-cells-container" flex="1"/>
+ <spacer flex="1"></spacer>
+ </toolbar>
+
+ <vbox id="overview-pane">
+ <hbox id="markers-overview"/>
+ <hbox id="memory-overview"/>
+ <hbox id="time-framerate"/>
</vbox>
+ <deck id="details-pane" flex="1">
+ <hbox id="waterfall-view" flex="1">
+ <vbox id="waterfall-breakdown" flex="1" />
+ <splitter class="devtools-side-splitter"/>
+ <vbox id="waterfall-details"
+ class="theme-sidebar"
+ width="150"
+ height="150"/>
+ </hbox>
- <hbox id="flamegraph-view" flex="1">
- </hbox>
- </deck>
- </vbox>
+ <vbox id="calltree-view" flex="1">
+ <hbox class="call-tree-headers-container">
+ <label class="plain call-tree-header"
+ type="duration"
+ crop="end"
+ value="&profilerUI.table.totalDuration;"/>
+ <label class="plain call-tree-header"
+ type="percentage"
+ crop="end"
+ value="&profilerUI.table.totalPercentage;"/>
+ <label class="plain call-tree-header"
+ type="self-duration"
+ crop="end"
+ value="&profilerUI.table.selfDuration;"/>
+ <label class="plain call-tree-header"
+ type="self-percentage"
+ crop="end"
+ value="&profilerUI.table.selfPercentage;"/>
+ <label class="plain call-tree-header"
+ type="samples"
+ crop="end"
+ value="&profilerUI.table.samples;"/>
+ <label class="plain call-tree-header"
+ type="function"
+ crop="end"
+ value="&profilerUI.table.function;"/>
+ </hbox>
+ <vbox class="call-tree-cells-container" flex="1"/>
+ </vbox>
+ <hbox id="flamegraph-view" flex="1">
+ </hbox>
+ </deck>
+ </vbox>
+ </hbox>
</window>
diff --git a/browser/devtools/performance/test/browser.ini b/browser/devtools/performance/test/browser.ini
index 430a4a3..24f957d 100644
--- a/browser/devtools/performance/test/browser.ini
+++ b/browser/devtools/performance/test/browser.ini
@@ -34,8 +34,11 @@ support-files =
[browser_perf-overview-selection-03.js]
[browser_perf-shared-connection-02.js]
[browser_perf-shared-connection-03.js]
# [browser_perf-shared-connection-04.js] bug 1077464
[browser_perf-ui-recording.js]
[browser_perf_recordings-io-01.js]
[browser_perf_recordings-io-02.js]
[browser_perf_recordings-io-03.js]
+[browser_perf-recording-selected-01.js]
+[browser_perf-recording-selected-02.js]
+[browser_perf-recording-selected-03.js]
diff --git a/browser/devtools/performance/test/browser_perf-recording-selected-01.js b/browser/devtools/performance/test/browser_perf-recording-selected-01.js
new file mode 100644
index 0000000..166b228
--- /dev/null
+++ b/browser/devtools/performance/test/browser_perf-recording-selected-01.js