|
3 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 | 4 | // Parses the ART trace format and converts it to the Gecko profile format. |
5 | 5 |
|
| 6 | +import type { |
| 7 | + IndexIntoFrameTable, |
| 8 | + IndexIntoStackTable, |
| 9 | +} from 'firefox-profiler/types'; |
| 10 | + |
6 | 11 | // These profiles are obtained from Android in two ways: |
7 | 12 | // - Programmatically, from the Debug API: https://developer.android.com/studio/profile/cpu-profiler#debug-api |
8 | 13 | // - Or via the profiler UI in Android Studio. |
@@ -566,7 +571,7 @@ function procureSamplingInterval(trace: ArtTrace) { |
566 | 571 |
|
567 | 572 | // Gather up to 500 time deltas between method actions on a thread. |
568 | 573 | const deltas: number[] = []; |
569 | | - const previousTimestampByThread = new Map(); |
| 574 | + const previousTimestampByThread = new Map<number, number>(); |
570 | 575 | const numberOfActionsToConsider = Math.min(500, methodActions.length); |
571 | 576 | for (let i = 0; i < numberOfActionsToConsider; i++) { |
572 | 577 | const { tid, globalTime } = methodActions[i]; |
@@ -621,7 +626,7 @@ export function getSpecialCategory( |
621 | 626 | return s.substring(0, firstPeriodPos); |
622 | 627 | } |
623 | 628 |
|
624 | | - const significantSegmentCounter = new Map(); |
| 629 | + const significantSegmentCounter = new Map<string, number>(); |
625 | 630 | for (let i = 0; i < methods.length; i++) { |
626 | 631 | const significantSegment = getSignificantNamespaceSegment( |
627 | 632 | methods[i].className |
@@ -791,8 +796,8 @@ class ThreadBuilder { |
791 | 796 |
|
792 | 797 | _currentStack: number | null = null; |
793 | 798 | _nextSampleTimestamp = 0; |
794 | | - _stackMap = new Map(); |
795 | | - _frameMap = new Map(); |
| 799 | + _stackMap = new Map<string, IndexIntoStackTable>(); |
| 800 | + _frameMap = new Map<number, IndexIntoFrameTable>(); |
796 | 801 | _registerTime = 0; |
797 | 802 | _name; |
798 | 803 | _pid; |
@@ -943,7 +948,7 @@ export function convertArtTraceProfile( |
943 | 948 | const { summaryDetails, threads, methods, methodActions } = trace; |
944 | 949 | const categoryInfo = new CategoryInfo(methods); |
945 | 950 | const methodMap = new Map(methods.map((m) => [m.methodId, m])); |
946 | | - const threadBuilderMap = new Map(); |
| 951 | + const threadBuilderMap = new Map<number, ThreadBuilder>(); |
947 | 952 |
|
948 | 953 | if (methodActions.length > 0) { |
949 | 954 | for (let i = 0; i < methodActions.length; i++) { |
|
0 commit comments