OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
398 } | 398 } |
399 var categoriesArray = [ | 399 var categoriesArray = [ |
400 "-*", | 400 "-*", |
401 disabledByDefault("devtools.timeline"), | 401 disabledByDefault("devtools.timeline"), |
402 disabledByDefault("devtools.timeline.frame"), | 402 disabledByDefault("devtools.timeline.frame"), |
403 WebInspector.TracingModel.ConsoleEventCategory | 403 WebInspector.TracingModel.ConsoleEventCategory |
404 ]; | 404 ]; |
405 if (captureCauses || enableJSSampling) | 405 if (captureCauses || enableJSSampling) |
406 categoriesArray.push(disabledByDefault("devtools.timeline.stack")); | 406 categoriesArray.push(disabledByDefault("devtools.timeline.stack")); |
407 if (enableJSSampling) | 407 if (enableJSSampling) |
408 this._startCpuProfilingOnAllTargets(); | 408 categoriesArray.push(disabledByDefault("devtools.js.profile")); |
409 if (captureCauses && Runtime.experiments.isEnabled("timelineInvalidation Tracking")) | 409 if (captureCauses && Runtime.experiments.isEnabled("timelineInvalidation Tracking")) |
410 categoriesArray.push(disabledByDefault("devtools.timeline.invalidati onTracking")); | 410 categoriesArray.push(disabledByDefault("devtools.timeline.invalidati onTracking")); |
411 if (capturePictures) { | 411 if (capturePictures) { |
412 categoriesArray = categoriesArray.concat([ | 412 categoriesArray = categoriesArray.concat([ |
413 disabledByDefault("devtools.timeline.layers"), | 413 disabledByDefault("devtools.timeline.layers"), |
414 disabledByDefault("devtools.timeline.picture"), | 414 disabledByDefault("devtools.timeline.picture"), |
415 disabledByDefault("blink.graphics_context_annotations")]); | 415 disabledByDefault("blink.graphics_context_annotations")]); |
416 } | 416 } |
417 var categories = categoriesArray.join(","); | 417 var categories = categoriesArray.join(","); |
418 this._startRecordingWithCategories(categories); | 418 this._startRecordingWithCategories(categories); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
543 if (error) | 543 if (error) |
544 WebInspector.console.error(error); | 544 WebInspector.console.error(error); |
545 } | 545 } |
546 }, | 546 }, |
547 | 547 |
548 /** | 548 /** |
549 * @param {string} categories | 549 * @param {string} categories |
550 */ | 550 */ |
551 _startRecordingWithCategories: function(categories) | 551 _startRecordingWithCategories: function(categories) |
552 { | 552 { |
553 if (categories.indexOf("devtools.js.profile") >= 0) | |
yurys
2014/11/14 13:25:26
Let's pass it as explicit enableJSSampling paramet
alph
2014/11/14 15:01:59
Done.
| |
554 this._startCpuProfilingOnAllTargets(); | |
553 this._tracingManager.start(categories, ""); | 555 this._tracingManager.start(categories, ""); |
554 }, | 556 }, |
555 | 557 |
556 _onTracingStarted: function() | 558 _onTracingStarted: function() |
557 { | 559 { |
558 this._startCollectingTraceEvents(false); | 560 this._startCollectingTraceEvents(false); |
559 }, | 561 }, |
560 | 562 |
561 /** | 563 /** |
562 * @param {boolean} fromFile | 564 * @param {boolean} fromFile |
(...skipping 27 matching lines...) Expand all Loading... | |
590 /** | 592 /** |
591 * @param {!WebInspector.Target} target | 593 * @param {!WebInspector.Target} target |
592 * @param {?Protocol.Error} error | 594 * @param {?Protocol.Error} error |
593 * @param {?ProfilerAgent.CPUProfile} cpuProfile | 595 * @param {?ProfilerAgent.CPUProfile} cpuProfile |
594 */ | 596 */ |
595 _didStopRecordingJSSamples: function(target, error, cpuProfile) | 597 _didStopRecordingJSSamples: function(target, error, cpuProfile) |
596 { | 598 { |
597 if (error) | 599 if (error) |
598 WebInspector.console.error(error); | 600 WebInspector.console.error(error); |
599 if (!this._cpuProfiles) | 601 if (!this._cpuProfiles) |
600 this._cpuProfiles = {}; | 602 this._cpuProfiles = new Map(); |
601 this._cpuProfiles[target.id()] = cpuProfile; | 603 this._cpuProfiles.set(target.id(), cpuProfile); |
602 }, | 604 }, |
603 | 605 |
604 _didStopRecordingTraceEvents: function() | 606 _didStopRecordingTraceEvents: function() |
605 { | 607 { |
606 this._tracingModel.tracingComplete(); | 608 this._tracingModel.tracingComplete(); |
607 | 609 |
608 var events = this._tracingModel.devtoolsPageMetadataEvents(); | 610 var metaEvents = this._tracingModel.devtoolsPageMetadataEvents(); |
609 var workerMetadataEvents = this._tracingModel.devtoolsWorkerMetadataEven ts(); | 611 var workerMetadataEvents = this._tracingModel.devtoolsWorkerMetadataEven ts(); |
610 | 612 |
611 this._resetProcessingState(); | 613 this._resetProcessingState(); |
612 for (var i = 0, length = events.length; i < length; i++) { | 614 for (var i = 0, length = metaEvents.length; i < length; i++) { |
613 var event = events[i]; | 615 var metaEvent = metaEvents[i]; |
614 var process = event.thread.process(); | 616 var process = metaEvent.thread.process(); |
615 var startTime = event.startTime; | 617 var startTime = metaEvent.startTime; |
616 | 618 |
617 var endTime = Infinity; | 619 var endTime = Infinity; |
618 if (i + 1 < length) | 620 if (i + 1 < length) |
619 endTime = events[i + 1].startTime; | 621 endTime = metaEvents[i + 1].startTime; |
620 | 622 |
621 var threads = process.sortedThreads(); | 623 var threads = process.sortedThreads(); |
622 for (var j = 0; j < threads.length; j++) { | 624 for (var j = 0; j < threads.length; j++) { |
623 var thread = threads[j]; | 625 var thread = threads[j]; |
624 if (thread.name() === "WebCore: Worker" && workerMetadataEvents. every(function(e) { return e.args["data"]["workerThreadId"] !== thread.id(); })) | 626 var workerId = 0; |
625 continue; | 627 if (thread.name() === "WebCore: Worker") { |
626 this._processThreadEvents(startTime, endTime, event.thread, thre ad); | 628 for (var k = 0; k < workerMetadataEvents.length; ++k) { |
629 var eventData = workerMetadataEvents[k].args["data"]; | |
630 if (eventData["workerThreadId"] === thread.id()) { | |
631 workerId = eventData["workerId"]; | |
632 break; | |
633 } | |
634 } | |
635 if (!workerId) | |
636 continue; | |
637 } | |
638 this._processThreadEvents(startTime, endTime, metaEvent.thread, thread, workerId); | |
627 } | 639 } |
628 } | 640 } |
629 this._resetProcessingState(); | 641 this._resetProcessingState(); |
630 | 642 |
631 this._inspectedTargetEvents.sort(WebInspector.TracingModel.Event.compare StartTime); | 643 this._inspectedTargetEvents.sort(WebInspector.TracingModel.Event.compare StartTime); |
632 | 644 |
633 this._cpuProfiles = null; | 645 this._cpuProfiles = null; |
634 | 646 |
635 this._buildTimelineRecords(); | 647 this._buildTimelineRecords(); |
636 this.dispatchEventToListeners(WebInspector.TimelineModel.Events.Recordin gStopped); | 648 this.dispatchEventToListeners(WebInspector.TimelineModel.Events.Recordin gStopped); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
746 this._lastRecalculateStylesEvent = null; | 758 this._lastRecalculateStylesEvent = null; |
747 this._currentScriptEvent = null; | 759 this._currentScriptEvent = null; |
748 this._eventStack = []; | 760 this._eventStack = []; |
749 }, | 761 }, |
750 | 762 |
751 /** | 763 /** |
752 * @param {number} startTime | 764 * @param {number} startTime |
753 * @param {?number} endTime | 765 * @param {?number} endTime |
754 * @param {!WebInspector.TracingModel.Thread} mainThread | 766 * @param {!WebInspector.TracingModel.Thread} mainThread |
755 * @param {!WebInspector.TracingModel.Thread} thread | 767 * @param {!WebInspector.TracingModel.Thread} thread |
768 * @param {number} workerId | |
756 */ | 769 */ |
757 _processThreadEvents: function(startTime, endTime, mainThread, thread) | 770 _processThreadEvents: function(startTime, endTime, mainThread, thread, worke rId) |
758 { | 771 { |
759 var events = thread.events(); | 772 var events = thread.events(); |
760 var length = events.length; | 773 var length = events.length; |
761 var i = events.lowerBound(startTime, function (time, event) { return tim e - event.startTime }); | 774 var i = events.lowerBound(startTime, function (time, event) { return tim e - event.startTime }); |
762 | 775 |
763 var threadEvents; | 776 var threadEvents; |
764 var virtualThread = null; | 777 var virtualThread = null; |
765 if (thread === mainThread) { | 778 if (thread === mainThread) { |
766 threadEvents = this._mainThreadEvents; | 779 threadEvents = this._mainThreadEvents; |
767 this._mainThreadAsyncEvents = this._mainThreadAsyncEvents.concat(thr ead.asyncEvents()); | 780 this._mainThreadAsyncEvents = this._mainThreadAsyncEvents.concat(thr ead.asyncEvents()); |
768 } else { | 781 } else { |
769 virtualThread = new WebInspector.TimelineModel.VirtualThread(thread. name()); | 782 virtualThread = new WebInspector.TimelineModel.VirtualThread(thread. name()); |
770 threadEvents = virtualThread.events; | 783 threadEvents = virtualThread.events; |
771 virtualThread.asyncEvents = virtualThread.asyncEvents.concat(thread. asyncEvents()); | 784 virtualThread.asyncEvents = virtualThread.asyncEvents.concat(thread. asyncEvents()); |
772 this._virtualThreads.push(virtualThread); | 785 this._virtualThreads.push(virtualThread); |
773 } | 786 } |
774 | 787 |
775 this._eventStack = []; | 788 this._eventStack = []; |
776 for (; i < length; i++) { | 789 for (; i < length; i++) { |
777 var event = events[i]; | 790 var event = events[i]; |
778 if (endTime && event.startTime >= endTime) | 791 if (endTime && event.startTime >= endTime) |
779 break; | 792 break; |
780 this._processEvent(event); | 793 this._processEvent(event); |
781 threadEvents.push(event); | 794 threadEvents.push(event); |
782 this._inspectedTargetEvents.push(event); | 795 this._inspectedTargetEvents.push(event); |
783 } | 796 } |
784 | 797 |
785 if (this._cpuProfiles && thread.target()) { | 798 if (!this._cpuProfiles) |
786 var cpuProfile = this._cpuProfiles[thread.target().id()]; | 799 return; |
787 if (cpuProfile) { | 800 var target; |
788 var jsSamples = WebInspector.TimelineJSProfileProcessor.generate TracingEventsFromCpuProfile(cpuProfile, thread); | 801 if (thread === mainThread) |
789 var mergedEvents = threadEvents.mergeOrdered(jsSamples, WebInspe ctor.TracingModel.Event.orderedCompareStartTime); | 802 target = WebInspector.targetManager.mainTarget(); |
790 var jsFrameEvents = WebInspector.TimelineJSProfileProcessor.gene rateJSFrameEvents(mergedEvents); | 803 else |
791 mergedEvents = jsFrameEvents.mergeOrdered(mergedEvents, WebInspe ctor.TracingModel.Event.orderedCompareStartTime); | 804 target = WebInspector.workerTargetManager && WebInspector.workerTarg etManager.targetByWorkerId(workerId); |
yurys
2014/11/14 13:25:26
When can WebInspector.workerTargetManager be null?
alph
2014/11/14 15:01:59
before the main target is created. It is obviously
| |
792 if (virtualThread) | 805 if (!target) |
793 virtualThread.events = mergedEvents; | 806 return; |
794 else | 807 var cpuProfile = this._cpuProfiles.get(target.id()); |
795 this._mainThreadEvents = mergedEvents; | 808 if (!cpuProfile) |
796 this._inspectedTargetEvents = this._inspectedTargetEvents.concat (jsSamples, jsFrameEvents); | 809 return; |
797 } | 810 this._cpuProfiles.delete(target.id()); |
798 } | 811 var jsSamples = WebInspector.TimelineJSProfileProcessor.generateTracingE ventsFromCpuProfile(cpuProfile, thread); |
812 var mergedEvents = threadEvents.mergeOrdered(jsSamples, WebInspector.Tra cingModel.Event.orderedCompareStartTime); | |
813 var jsFrameEvents = WebInspector.TimelineJSProfileProcessor.generateJSFr ameEvents(mergedEvents); | |
814 mergedEvents = jsFrameEvents.mergeOrdered(mergedEvents, WebInspector.Tra cingModel.Event.orderedCompareStartTime); | |
815 if (virtualThread) | |
816 virtualThread.events = mergedEvents; | |
817 else | |
818 this._mainThreadEvents = mergedEvents; | |
819 this._inspectedTargetEvents = this._inspectedTargetEvents.concat(jsSampl es, jsFrameEvents); | |
799 }, | 820 }, |
800 | 821 |
801 /** | 822 /** |
802 * @param {!WebInspector.TracingModel.Event} event | 823 * @param {!WebInspector.TracingModel.Event} event |
803 */ | 824 */ |
804 _processEvent: function(event) | 825 _processEvent: function(event) |
805 { | 826 { |
806 var recordTypes = WebInspector.TimelineModel.RecordType; | 827 var recordTypes = WebInspector.TimelineModel.RecordType; |
807 | 828 |
808 var eventStack = this._eventStack; | 829 var eventStack = this._eventStack; |
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1688 _initializePerFrameState: function() | 1709 _initializePerFrameState: function() |
1689 { | 1710 { |
1690 /** @type {!Array.<!WebInspector.InvalidationTrackingEvent>} */ | 1711 /** @type {!Array.<!WebInspector.InvalidationTrackingEvent>} */ |
1691 this._invalidationEvents = []; | 1712 this._invalidationEvents = []; |
1692 this._lastStyleRecalcEventIndex = 0; | 1713 this._lastStyleRecalcEventIndex = 0; |
1693 this._lastLayoutEventIndex = 0; | 1714 this._lastLayoutEventIndex = 0; |
1694 this._lastPaintWithLayer = undefined; | 1715 this._lastPaintWithLayer = undefined; |
1695 this._didPaint = false; | 1716 this._didPaint = false; |
1696 } | 1717 } |
1697 } | 1718 } |
OLD | NEW |