Skip to content

Commit d3972c0

Browse files
committed
Unit test for JankFrames
1 parent a01a7b1 commit d3972c0

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

PerfettoCds/Pipeline/CompositeDataCookers/PerfettoFrameEventCooker.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ void PopulateFrameEvents(IDataExtensionRetrieval requiredData, ProcessedEventDat
6060
// The sched slice data contains the timings, CPU, priority, and end state info. We get the process and thread from
6161
// those respective tables
6262
var joinedActual = from frame in actualFrameData
63-
join process in processData on frame.Upid equals process.Upid into pd
63+
join process in processData on frame.Upid equals process.Upid into pd orderby frame.Id
6464
from process in pd.DefaultIfEmpty()
6565
select new { frame, process };
6666
var joinedExpected = from frame in expectedFrameData
67-
join process in processData on frame.Upid equals process.Upid into pd
67+
join process in processData on frame.Upid equals process.Upid into pd orderby frame.Id
6868
from process in pd.DefaultIfEmpty()
6969
select new { frame, process };
7070

PerfettoUnitTest/PerfettoUnitTest.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ public static void LoadTrace(string traceFilename)
5757
runtime.EnableCooker(PerfettoPluginConstants.StackProfileFrameCookerPath);
5858
runtime.EnableCooker(PerfettoPluginConstants.StackProfileMappingCookerPath);
5959
runtime.EnableCooker(PerfettoPluginConstants.StackProfileSymbolCookerPath);
60+
runtime.EnableCooker(PerfettoPluginConstants.ExpectedFrameCookerPath);
61+
runtime.EnableCooker(PerfettoPluginConstants.ActualFrameCookerPath);
6062

6163
// Enable the composite data cookers
6264
runtime.EnableCooker(PerfettoPluginConstants.GenericEventCookerPath);
@@ -66,6 +68,7 @@ public static void LoadTrace(string traceFilename)
6668
runtime.EnableCooker(PerfettoPluginConstants.FtraceEventCookerPath);
6769
runtime.EnableCooker(PerfettoPluginConstants.CpuFrequencyEventCookerPath);
6870
runtime.EnableCooker(PerfettoPluginConstants.CpuSamplingEventCookerPath);
71+
runtime.EnableCooker(PerfettoPluginConstants.FrameEventCookerPath);
6972

7073
// Process our data.
7174
RuntimeExecutionResults = runtime.Process();
@@ -228,6 +231,28 @@ public void TestChromeTrace()
228231
Assert.IsTrue(logcatEventData.Count == 43);
229232
Assert.IsTrue(logcatEventData[0].Message == "type: 97 score: 0.8\n");
230233
Assert.IsTrue(logcatEventData[1].ProcessName == "Browser");
234+
}
235+
236+
[TestMethod]
237+
public void TestJankFrameTrace()
238+
{
239+
LoadTrace(@"..\..\..\..\TestData\Perfetto\jankFrame.pftrace");
240+
241+
var frameEvents = RuntimeExecutionResults.QueryOutput<ProcessedEventData<PerfettoFrameEvent>>(
242+
new DataOutputPath(PerfettoPluginConstants.FrameEventCookerPath, nameof(PerfettoFrameEventCooker.FrameEvents)));
243+
244+
Assert.IsTrue(frameEvents.Count == 4827);
245+
Assert.IsTrue(frameEvents[0].ProcessName == "com.android.systemui");
246+
Assert.IsTrue(frameEvents[1].StartTimestamp.ToNanoseconds == 16666666);
247+
Assert.IsTrue(frameEvents[3007].FrameType == "Actual");
248+
Assert.IsTrue(frameEvents[3007].JankTag == "Self Jank");
249+
Assert.IsTrue(frameEvents[3007].DisplayToken == 20016);
250+
Assert.IsTrue(frameEvents[3926].GpuComposition == "0");
251+
Assert.IsTrue(frameEvents[3926].PresentType == "Late Present");
252+
Assert.IsTrue(frameEvents[3926].DisplayToken == 21423);
253+
Assert.IsTrue(frameEvents[3926].PredictionType == "Valid Prediction");
254+
Assert.IsTrue(frameEvents[3926].JankType == "SurfaceFlinger CPU Deadline Missed, App Deadline Missed, Buffer Stuffing");
255+
Assert.IsTrue(frameEvents[3926].AppOnTime == "0");
231256
}
232257
}
233258
}
26.4 MB
Binary file not shown.

0 commit comments

Comments
 (0)