How to test performance?
I always worry SharpConstraintLayout can't be used in real word, because i don't know the performance, test in core is fast, but in ui, it need calculate more things, i don't know how to test it. I only know, when i resize Windows app, flow test like slow.
Goolgle use androidx.constraintlayout , i believe it meet needs. I try to add a framerate label and a androidx.constraintlayout flow test to compare with sharpconstraintlayout at a5ec59b7c03bc54a0143389faee82d13039cdaef, get result:
https://user-images.githubusercontent.com/17793881/222618570-9ac0a106-9c64-4d30-a991-b3295dca9b11.mp4
We can see when resize window of app that run in Windows subsystem for Android, androidx.constraintlayout and sharpconstraintlayout all get low framerate. But when change child, framerate is ok.
Maui framerate < 60 when there are 200 controls:
https://user-images.githubusercontent.com/17793881/222873579-9b6afab0-8db2-4ac9-bc90-5e73b4e8aec3.mp4
SharpConstraintLayout.Native is ok when there are 200 controls:
https://user-images.githubusercontent.com/17793881/222875017-e2cf85e8-6a5b-448c-8da8-0660804c6804.mp4
when use net6, i see log show measure many times, tonight i try use net7, measure little times, tomorrow i will test it. another i find i can directly load measure method to calculate time of measure, maybe i can use it to compare other layout
200个控件在flow里慢的原因主要是重复布局了, 可能导致重复布局的因素是文本输入控件的重复布局
- 我因为Entry在iOS上输入时显示省略号, 在TextChange里刷新了View, log中更改文本时显示两次布局过程
- Editor控件输入时导致多次布局, 暂且不知道为什么
- remove entry in flow performance test, when entry/editor is wrapcontent, will generate many bug. when we use entry or editor, usually will constrain it.
- i also obsolete baseline api, not calculate it will save time
I see log always have some bug about measure order, breakpoint sometimes not work, I feel best way test it is use a complex collectionview, see fps when fast scroll.
When i use ConstraintLayout in https://github.com/xtuzy/MauiUICollectionView, I know a way to test performance, use IView.Measure can get time fo measure.
Now test code see 49a27fe6521744731a88946cc9c376462b342d2f , it use a CollectonView, use Official Layout and ConstraintLayout to layout item, record time of measure. Result: Official Layout faster than SharpConstraintLayout
I run it on android old phone, it scroll well: https://twitter.com/H_N_B_D_D/status/1676483931967979520?t=8Qk2XL0iefq5Ka31NvL1Ng&s=19
One bug is it is slow on start, use official layout also.