Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
22dd0f42
Unverified
Commit
22dd0f42
authored
Dec 11, 2021
by
Jia Hao
Committed by
GitHub
Dec 11, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_test] Fix incorrect missed budget count (#95003)
parent
df4d851f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
141 additions
and
52 deletions
+141
-52
frame_timing_summarizer.dart
packages/flutter_test/lib/src/frame_timing_summarizer.dart
+11
-6
frame_timing_summarizer_test.dart
packages/flutter_test/test/frame_timing_summarizer_test.dart
+130
-46
No files found.
packages/flutter_test/lib/src/frame_timing_summarizer.dart
View file @
22dd0f42
...
...
@@ -294,16 +294,21 @@ class FrameTimingSummarizer {
};
}
//
The following helper functions require data sorted
//
return the 100*p-th percentile of the data
//
/ Returns the 100*p-th percentile of [data].
///
//
/ [data] must be sorted in ascending order.
T
_findPercentile
<
T
>(
List
<
T
>
data
,
double
p
)
{
assert
(
p
>=
0
&&
p
<=
1
);
return
data
[((
data
.
length
-
1
)
*
p
).
round
()];
}
// return the number of items in data that > threshold
/// Returns the number of elements in [data] that exceed [threshold].
///
/// [data] must be sorted in ascending order.
int
_countExceed
<
T
extends
Comparable
<
T
>>(
List
<
T
>
data
,
T
threshold
)
{
return
data
.
length
-
data
.
indexWhere
((
T
datum
)
=>
datum
.
compareTo
(
threshold
)
>
0
);
final
int
exceedsThresholdIndex
=
data
.
indexWhere
((
T
datum
)
=>
datum
.
compareTo
(
threshold
)
>
0
);
if
(
exceedsThresholdIndex
==
-
1
)
{
return
0
;
}
return
data
.
length
-
exceedsThresholdIndex
;
}
packages/flutter_test/test/frame_timing_summarizer_test.dart
View file @
22dd0f42
...
...
@@ -7,51 +7,135 @@ import 'dart:ui';
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
test
(
'Test FrameTimingSummarizer'
,
()
{
List
<
int
>
vsyncTimes
=
<
int
>[
for
(
int
i
=
0
;
i
<
100
;
i
+=
1
)
100
*
(
i
+
1
),
];
List
<
int
>
buildTimes
=
<
int
>[
for
(
int
i
=
0
;
i
<
100
;
i
+=
1
)
vsyncTimes
[
i
]
+
1000
*
(
i
+
1
),
];
List
<
int
>
rasterTimes
=
<
int
>[
for
(
int
i
=
0
;
i
<
100
;
i
+=
1
)
1000
*
(
i
+
1
)
+
1000
,
];
// reversed to make sure sort is working.
buildTimes
=
buildTimes
.
reversed
.
toList
();
rasterTimes
=
rasterTimes
.
reversed
.
toList
();
vsyncTimes
=
vsyncTimes
.
reversed
.
toList
();
final
List
<
FrameTiming
>
inputData
=
<
FrameTiming
>[
for
(
int
i
=
0
;
i
<
100
;
i
+=
1
)
FrameTiming
(
vsyncStart:
0
,
buildStart:
vsyncTimes
[
i
],
buildFinish:
buildTimes
[
i
],
rasterStart:
500
,
rasterFinish:
rasterTimes
[
i
],
// Wall time should not be used in any profiling metrics.
// It is primarily to correlate with external tools' measurement.
rasterFinishWallTime:
0
,
),
];
final
FrameTimingSummarizer
summary
=
FrameTimingSummarizer
(
inputData
);
expect
(
summary
.
averageFrameBuildTime
.
inMicroseconds
,
50500
);
expect
(
summary
.
p90FrameBuildTime
.
inMicroseconds
,
90000
);
expect
(
summary
.
p99FrameBuildTime
.
inMicroseconds
,
99000
);
expect
(
summary
.
worstFrameBuildTime
.
inMicroseconds
,
100000
);
expect
(
summary
.
missedFrameBuildBudget
,
84
);
expect
(
summary
.
averageFrameRasterizerTime
.
inMicroseconds
,
51000
);
expect
(
summary
.
p90FrameRasterizerTime
.
inMicroseconds
,
90500
);
expect
(
summary
.
p99FrameRasterizerTime
.
inMicroseconds
,
99500
);
expect
(
summary
.
worstFrameRasterizerTime
.
inMicroseconds
,
100500
);
expect
(
summary
.
missedFrameRasterizerBudget
,
85
);
expect
(
summary
.
frameBuildTime
.
length
,
100
);
expect
(
summary
.
averageVsyncOverhead
.
inMicroseconds
,
5050
);
expect
(
summary
.
p90VsyncOverhead
.
inMicroseconds
,
9000
);
expect
(
summary
.
p99VsyncOverhead
.
inMicroseconds
,
9900
);
expect
(
summary
.
worstVsyncOverhead
.
inMicroseconds
,
10000
);
group
(
FrameTimingSummarizer
,
()
{
test
(
'calculates all fields'
,
()
{
List
<
int
>
vsyncTimes
=
<
int
>[
for
(
int
i
=
0
;
i
<
100
;
i
+=
1
)
100
*
(
i
+
1
),
];
List
<
int
>
buildTimes
=
<
int
>[
for
(
int
i
=
0
;
i
<
100
;
i
+=
1
)
vsyncTimes
[
i
]
+
1000
*
(
i
+
1
),
];
List
<
int
>
rasterTimes
=
<
int
>[
for
(
int
i
=
0
;
i
<
100
;
i
+=
1
)
1000
*
(
i
+
1
)
+
1000
,
];
// reversed to make sure sort is working.
buildTimes
=
buildTimes
.
reversed
.
toList
();
rasterTimes
=
rasterTimes
.
reversed
.
toList
();
vsyncTimes
=
vsyncTimes
.
reversed
.
toList
();
final
List
<
FrameTiming
>
inputData
=
<
FrameTiming
>[
for
(
int
i
=
0
;
i
<
100
;
i
+=
1
)
FrameTiming
(
vsyncStart:
0
,
buildStart:
vsyncTimes
[
i
],
buildFinish:
buildTimes
[
i
],
rasterStart:
500
,
rasterFinish:
rasterTimes
[
i
],
// Wall time should not be used in any profiling metrics.
// It is primarily to correlate with external tools' measurement.
rasterFinishWallTime:
0
,
),
];
final
FrameTimingSummarizer
summary
=
FrameTimingSummarizer
(
inputData
);
expect
(
summary
.
averageFrameBuildTime
.
inMicroseconds
,
50500
);
expect
(
summary
.
p90FrameBuildTime
.
inMicroseconds
,
90000
);
expect
(
summary
.
p99FrameBuildTime
.
inMicroseconds
,
99000
);
expect
(
summary
.
worstFrameBuildTime
.
inMicroseconds
,
100000
);
expect
(
summary
.
missedFrameBuildBudget
,
84
);
expect
(
summary
.
averageFrameRasterizerTime
.
inMicroseconds
,
51000
);
expect
(
summary
.
p90FrameRasterizerTime
.
inMicroseconds
,
90500
);
expect
(
summary
.
p99FrameRasterizerTime
.
inMicroseconds
,
99500
);
expect
(
summary
.
worstFrameRasterizerTime
.
inMicroseconds
,
100500
);
expect
(
summary
.
missedFrameRasterizerBudget
,
85
);
expect
(
summary
.
frameBuildTime
.
length
,
100
);
expect
(
summary
.
averageVsyncOverhead
.
inMicroseconds
,
5050
);
expect
(
summary
.
p90VsyncOverhead
.
inMicroseconds
,
9000
);
expect
(
summary
.
p99VsyncOverhead
.
inMicroseconds
,
9900
);
expect
(
summary
.
worstVsyncOverhead
.
inMicroseconds
,
10000
);
});
group
(
'missed budget count'
,
()
{
test
(
'when single element missed budget'
,
()
{
final
FrameTimingSummarizer
summary
=
FrameTimingSummarizer
(<
FrameTiming
>[
FrameTiming
(
buildStart:
0
,
buildFinish:
(
kBuildBudget
+
const
Duration
(
microseconds:
1
)).
inMicroseconds
,
vsyncStart:
0
,
rasterStart:
0
,
rasterFinish:
0
,
rasterFinishWallTime:
0
,
),
]);
expect
(
summary
.
missedFrameBuildBudget
,
1
);
});
test
(
'when single element within budget'
,
()
{
final
FrameTimingSummarizer
summary
=
FrameTimingSummarizer
(<
FrameTiming
>[
FrameTiming
(
buildStart:
0
,
buildFinish:
0
,
vsyncStart:
0
,
rasterStart:
0
,
rasterFinish:
0
,
rasterFinishWallTime:
0
,
),
]);
expect
(
summary
.
missedFrameBuildBudget
,
0
);
});
test
(
'when single element exactly within budget'
,
()
{
final
FrameTimingSummarizer
summary
=
FrameTimingSummarizer
(<
FrameTiming
>[
FrameTiming
(
buildStart:
0
,
buildFinish:
kBuildBudget
.
inMicroseconds
,
vsyncStart:
0
,
rasterStart:
0
,
rasterFinish:
0
,
rasterFinishWallTime:
0
,
),
]);
expect
(
summary
.
missedFrameBuildBudget
,
0
);
});
test
(
'when many missed budget'
,
()
{
final
FrameTimingSummarizer
summary
=
FrameTimingSummarizer
(<
FrameTiming
>[
FrameTiming
(
buildStart:
0
,
buildFinish:
0
,
vsyncStart:
0
,
rasterStart:
0
,
rasterFinish:
0
,
rasterFinishWallTime:
0
,
),
FrameTiming
(
buildStart:
0
,
buildFinish:
kBuildBudget
.
inMicroseconds
,
vsyncStart:
0
,
rasterStart:
0
,
rasterFinish:
0
,
rasterFinishWallTime:
0
,
),
FrameTiming
(
buildStart:
0
,
buildFinish:
(
kBuildBudget
+
const
Duration
(
microseconds:
1
)).
inMicroseconds
,
vsyncStart:
0
,
rasterStart:
0
,
rasterFinish:
0
,
rasterFinishWallTime:
0
,
),
FrameTiming
(
buildStart:
0
,
buildFinish:
(
kBuildBudget
+
const
Duration
(
microseconds:
2
)).
inMicroseconds
,
vsyncStart:
0
,
rasterStart:
0
,
rasterFinish:
0
,
rasterFinishWallTime:
0
,
),
]);
expect
(
summary
.
missedFrameBuildBudget
,
2
);
});
});
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment