Format transition viewer timestamps to the right type am: 9b0562b4d7
Original change: https://googleplex-android-review.googlesource.com/c/platform/development/+/23390677 Change-Id: I71ef2202e7477b6feaf37dca72dd706afe808d9c Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -127,6 +127,19 @@ export class TimeUtils {
|
||||
);
|
||||
}
|
||||
|
||||
static formattedKotlinTimestamp(time: any, timestampType: TimestampType): string {
|
||||
console.log('time', time);
|
||||
if (timestampType === TimestampType.ELAPSED) {
|
||||
return TimeUtils.format(new ElapsedTimestamp(BigInt(time.elapsedNanos.toString())));
|
||||
}
|
||||
|
||||
if (timestampType === TimestampType.REAL) {
|
||||
return TimeUtils.format(new RealTimestamp(BigInt(time.unixNanos.toString())));
|
||||
}
|
||||
|
||||
throw new Error('Unsupported timestamp');
|
||||
}
|
||||
|
||||
static TO_NANO = {
|
||||
ns: 1,
|
||||
ms: 1000000,
|
||||
|
||||
@@ -124,6 +124,13 @@ export class Trace<T> {
|
||||
return this.parser.getDescriptors();
|
||||
}
|
||||
|
||||
getTimestampType(): TimestampType {
|
||||
if (this.timestampType === undefined) {
|
||||
throw new Error('Trace no fully initialized yet!');
|
||||
}
|
||||
return this.timestampType;
|
||||
}
|
||||
|
||||
setFrameInfo(frameMap: FrameMap, framesRange: FramesRange | undefined) {
|
||||
if (frameMap.lengthEntries !== this.fullTrace.lengthEntries) {
|
||||
throw new Error('Attemped to set a frame map with incompatible number of entries');
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
import {assertDefined} from 'common/assert_utils';
|
||||
import {TimeUtils} from 'common/time_utils';
|
||||
import {LayerTraceEntry, Transition, WindowManagerState} from 'trace/flickerlib/common';
|
||||
import {ElapsedTimestamp} from 'trace/timestamp';
|
||||
import {Trace} from 'trace/trace';
|
||||
import {Traces} from 'trace/traces';
|
||||
import {TraceEntryFinder} from 'trace/trace_entry_finder';
|
||||
@@ -61,7 +60,17 @@ export class Presenter {
|
||||
const selectedTransition = this.uiData?.selectedTransition ?? undefined;
|
||||
const selectedTransitionPropertiesTree =
|
||||
this.uiData?.selectedTransitionPropertiesTree ?? undefined;
|
||||
return new UiData(transitions, selectedTransition, selectedTransitionPropertiesTree);
|
||||
|
||||
const timestampType = this.transitionTrace.getTimestampType();
|
||||
if (timestampType === undefined) {
|
||||
throw new Error('Missing timestamp type in trace!');
|
||||
}
|
||||
return new UiData(
|
||||
transitions,
|
||||
selectedTransition,
|
||||
timestampType,
|
||||
selectedTransitionPropertiesTree
|
||||
);
|
||||
}
|
||||
|
||||
private makeSelectedTransitionPropertiesTree(transition: Transition): PropertiesTreeNode {
|
||||
@@ -124,47 +133,42 @@ export class Presenter {
|
||||
properties.push({propertyKey: 'handler', propertyValue: transition.handler});
|
||||
}
|
||||
|
||||
const timestampType = this.transitionTrace.getTimestampType();
|
||||
|
||||
if (!transition.createTime.isMin) {
|
||||
properties.push({
|
||||
propertyKey: 'createTime',
|
||||
propertyValue: TimeUtils.format(
|
||||
new ElapsedTimestamp(BigInt(transition.createTime.elapsedNanos.toString()))
|
||||
),
|
||||
propertyValue: TimeUtils.formattedKotlinTimestamp(transition.createTime, timestampType),
|
||||
});
|
||||
}
|
||||
|
||||
if (!transition.sendTime.isMin) {
|
||||
properties.push({
|
||||
propertyKey: 'sendTime',
|
||||
propertyValue: TimeUtils.format(
|
||||
new ElapsedTimestamp(BigInt(transition.sendTime.elapsedNanos.toString()))
|
||||
),
|
||||
propertyValue: TimeUtils.formattedKotlinTimestamp(transition.sendTime, timestampType),
|
||||
});
|
||||
}
|
||||
|
||||
if (!transition.dispatchTime.isMin) {
|
||||
properties.push({
|
||||
propertyKey: 'dispatchTime',
|
||||
propertyValue: TimeUtils.format(
|
||||
new ElapsedTimestamp(BigInt(transition.dispatchTime.elapsedNanos.toString()))
|
||||
),
|
||||
propertyValue: TimeUtils.formattedKotlinTimestamp(transition.dispatchTime, timestampType),
|
||||
});
|
||||
}
|
||||
|
||||
if (!transition.finishTime.isMax) {
|
||||
properties.push({
|
||||
propertyKey: 'finishTime',
|
||||
propertyValue: TimeUtils.format(
|
||||
new ElapsedTimestamp(BigInt(transition.finishTime.elapsedNanos.toString()))
|
||||
),
|
||||
propertyValue: TimeUtils.formattedKotlinTimestamp(transition.finishTime, timestampType),
|
||||
});
|
||||
}
|
||||
|
||||
if (transition.mergeRequestTime) {
|
||||
properties.push({
|
||||
propertyKey: 'mergeRequestTime',
|
||||
propertyValue: TimeUtils.format(
|
||||
new ElapsedTimestamp(BigInt(transition.mergeRequestTime.elapsedNanos.toString()))
|
||||
propertyValue: TimeUtils.formattedKotlinTimestamp(
|
||||
transition.mergeRequestTime,
|
||||
timestampType
|
||||
),
|
||||
});
|
||||
}
|
||||
@@ -172,18 +176,14 @@ export class Presenter {
|
||||
if (transition.shellAbortTime) {
|
||||
properties.push({
|
||||
propertyKey: 'shellAbortTime',
|
||||
propertyValue: TimeUtils.format(
|
||||
new ElapsedTimestamp(BigInt(transition.shellAbortTime.elapsedNanos.toString()))
|
||||
),
|
||||
propertyValue: TimeUtils.formattedKotlinTimestamp(transition.shellAbortTime, timestampType),
|
||||
});
|
||||
}
|
||||
|
||||
if (transition.mergeTime) {
|
||||
properties.push({
|
||||
propertyKey: 'mergeTime',
|
||||
propertyValue: TimeUtils.format(
|
||||
new ElapsedTimestamp(BigInt(transition.mergeTime.elapsedNanos.toString()))
|
||||
),
|
||||
propertyValue: TimeUtils.formattedKotlinTimestamp(transition.mergeTime, timestampType),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -15,22 +15,16 @@
|
||||
*/
|
||||
|
||||
import {Transition} from 'trace/flickerlib/common';
|
||||
import {TimestampType} from 'trace/timestamp';
|
||||
import {PropertiesTreeNode} from 'viewers/common/ui_tree_utils';
|
||||
|
||||
export class UiData {
|
||||
constructor(
|
||||
transitions: Transition[],
|
||||
selectedTransition: Transition,
|
||||
selectedTransitionPropertiesTree?: PropertiesTreeNode
|
||||
) {
|
||||
this.entries = transitions;
|
||||
this.selectedTransition = selectedTransition;
|
||||
this.selectedTransitionPropertiesTree = selectedTransitionPropertiesTree;
|
||||
}
|
||||
public entries: Transition[],
|
||||
public selectedTransition: Transition,
|
||||
public timestampType: TimestampType,
|
||||
public selectedTransitionPropertiesTree?: PropertiesTreeNode
|
||||
) {}
|
||||
|
||||
entries: Transition[] = [];
|
||||
selectedTransition: Transition | undefined;
|
||||
selectedTransitionPropertiesTree: PropertiesTreeNode | undefined;
|
||||
|
||||
static EMPTY = new UiData([], undefined, undefined);
|
||||
static EMPTY = new UiData([], undefined, TimestampType.REAL, undefined);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
import {Component, ElementRef, Inject, Input} from '@angular/core';
|
||||
import {TimeUtils} from 'common/time_utils';
|
||||
import {Transition} from 'trace/flickerlib/common';
|
||||
import {ElapsedTimestamp} from 'trace/timestamp';
|
||||
import {ElapsedTimestamp, TimestampType} from 'trace/timestamp';
|
||||
import {Terminal} from 'viewers/common/ui_tree_utils';
|
||||
import {Events} from './events';
|
||||
import {UiData} from './ui_data';
|
||||
@@ -49,7 +49,7 @@ import {UiData} from './ui_data';
|
||||
</div>
|
||||
<div class="send-time">
|
||||
<span *ngIf="!transition.sendTime.isMin" class="mat-body-1">{{
|
||||
formattedElapsedTime(transition.sendTime.elapsedNanos.toString())
|
||||
formattedTime(transition.sendTime, uiData.timestampType)
|
||||
}}</span>
|
||||
<span *ngIf="transition.sendTime.isMin"> n/a </span>
|
||||
</div>
|
||||
@@ -58,9 +58,10 @@ import {UiData} from './ui_data';
|
||||
*ngIf="!transition.sendTime.isMin && !transition.finishTime.isMax"
|
||||
class="mat-body-1"
|
||||
>{{
|
||||
formattedElapsedTimeDiff(
|
||||
transition.sendTime.elapsedNanos.toString(),
|
||||
transition.finishTime.elapsedNanos.toString()
|
||||
formattedTimeDiff(
|
||||
transition.sendTime,
|
||||
transition.finishTime,
|
||||
uiData.timestampType
|
||||
)
|
||||
}}</span
|
||||
>
|
||||
@@ -296,14 +297,15 @@ export class ViewerTransitionsComponent {
|
||||
return maxOfRange;
|
||||
}
|
||||
|
||||
formattedElapsedTime(timeStringNanos: string): string {
|
||||
return TimeUtils.format(new ElapsedTimestamp(BigInt(timeStringNanos)));
|
||||
formattedTime(time: any, timestampType: TimestampType): string {
|
||||
return TimeUtils.formattedKotlinTimestamp(time, timestampType);
|
||||
}
|
||||
|
||||
formattedElapsedTimeDiff(timeStringNanos1: string, timeStringNanos2: string) {
|
||||
return TimeUtils.format(
|
||||
new ElapsedTimestamp(BigInt(timeStringNanos2) - BigInt(timeStringNanos1))
|
||||
formattedTimeDiff(time1: any, time2: any, timestampType: TimestampType): string {
|
||||
const timeDiff = new ElapsedTimestamp(
|
||||
BigInt(time2.elapsedNanos.toString()) - BigInt(time1.elapsedNanos.toString())
|
||||
);
|
||||
return TimeUtils.format(timeDiff);
|
||||
}
|
||||
|
||||
widthOf(transition: Transition) {
|
||||
|
||||
@@ -26,6 +26,7 @@ import {
|
||||
TransitionType,
|
||||
WmTransitionData,
|
||||
} from 'trace/flickerlib/common';
|
||||
import {TimestampType} from 'trace/timestamp';
|
||||
import {UiData} from './ui_data';
|
||||
import {ViewerTransitionsComponent} from './viewer_transitions_component';
|
||||
|
||||
@@ -80,8 +81,14 @@ function makeUiData(): UiData {
|
||||
|
||||
const selectedTransition = undefined;
|
||||
const selectedTransitionPropertiesTree = undefined;
|
||||
const timestampType = TimestampType.REAL;
|
||||
|
||||
return new UiData(transitions, selectedTransition, selectedTransitionPropertiesTree);
|
||||
return new UiData(
|
||||
transitions,
|
||||
selectedTransition,
|
||||
timestampType,
|
||||
selectedTransitionPropertiesTree
|
||||
);
|
||||
}
|
||||
|
||||
function createMockTransition(
|
||||
|
||||
Reference in New Issue
Block a user