What are the (hidden) costs regarding performance ...
# compose
h
z
Are there specific hidden costs you’re wondering about, or just if there are any in general?
h
General
z
Probably the biggest one would be if you’re providing a static composition local that changes over time, because it will require every composable in the content to recompose.
I’m not aware of any significant costs to simply providing a value otherwise. Reading a non-static composition local is slightly more expensive than reading a static one, because of the read tracking involved, but it’s not something to be worried about unless your benchmarks show otherwise.
h
So if I update the value "during" recomposition, it will recompose the sub content too. yeah, makes sense
I think, I just have to test it 😄
Do you know a good compose profiler/benchmark tool? Besides simple measuring the time
r
The Jetpack Benchmark library is the best way to write benchmarks
It tries to ensure consistent measurements in various ways
Note that beyond performance questions,
CompositionLocalProvider
can be a “dangerous” tool as it effectively create somewhat invisible dependencies
Which can make reusing composables more difficult/less obious
h
I know, you should avoid it. My usecase is subtree based relative routing.
Thanks for sharing Jetpack Benchmark, but is it possible to measure non ui composables?
r
Yes, esp. with microbenchmarks