<p>This answer will further only discuss a simple method to calculate <strong>DE</strong> for the Dense Scenario. This is sufficiently adequate to compare different chunksize-algorithms, since...</p>
<ol>
What does the shrinkWrap property do in Flutter?
... the DM is the part of the PM, which changes with different chunksize-algorithms employed.
I am new to Flutter and very eager to learn this technology. I cannot understand the work of shrinkWrap property in ListView. I couldn't understand the Flutter documentation.
... the Dense Scenario with equal computation durations per taskel depicts a "stable state", for which these time spans drop out of the equation. Any other scenario would just lead to random results since the ordering of taskels would matter.
If you do not set the shrinkWrap property, your ListView will be as big as its parent.
6.3.1 Absolute Distribution Efficiency (ADE)
If you set it to true, the list will wrap its content and be as big as it children allows it to be.
Usually a ListView (as well as GridView, PageView and CustomScrollView) tries to fill all the available space given by the parent element, even when the list items would require less space.
This basic efficiency can be calculated in general by dividing the Busy Share through the whole potential of the Parallel Schedule:
With shrinkWrap: true, you can change this behavior so that the ListView only occupies the space it needs (it will still scroll when there more items).
Absolute Distribution Efficiency (ADE) = Busy Share / Parallel Schedule
For the Dense Scenario, the simplified calculation-code looks like this:
# mp_utils.py
def calc_ade(n_workers, len_iterable, n_chunks, chunksize, last_chunk):
"""Calculate Absolute Distribution Efficiency (ADE).
`len_iterable` is not used, but contained to keep a consistent signature
with `calc_rde`.
"""
if n_workers == 1:
return 1
potential = (
((n_chunks // n_workers + (n_chunks % n_workers > 1)) * chunksize)
+ (n_chunks % n_workers == 1) * last_chunk
) * n_workers
n_full_chunks = n_chunks - (chunksize > last_chunk)
taskels_in_regular_chunks = n_full_chunks * chunksize
real = taskels_in_regular_chunks + (chunksize > last_chunk) * last_chunk
ade = real / potential
return ade
With shrinkWrap: false:
With shrinkWrap: true:
You can use this in AlertDialogs: When there are only a few items, make the dialog as small as possible. When there are many items, fill the screen height and make the list scrollable:
Every ScrollView (ListView , GridView , CustomScrollView) have a shrinkWrap property for determining the size of scrollDirection.
So ScrollView's scrollDirection can have 02 sizes.
If there is no Idling Share, Busy Share will be equal to Parallel Schedule, hence we get an ADE of 100%. In our simplified model, this is a scenario where all available processes will be busy through the whole time needed for processing all tasks. In other words, the whole job gets effectively parallelized to 100 percent.
Same size as parent size.
Same size as content size (All children size).
But why do I keep referring to PE as absolutePE here?
If ScrollView's shrinkWrap : false , Then ScrollView's scrollDirection size is same size as parent size.
To comprehend that, we have to consider a possible case for the chunksize (cs) which ensures maximal scheduling flexibility (also, the number of Highlanders there can be. Coincidence?):
__________________________________~ ONE ~__________________________________
If the ScrollView's shrinkWrap : true , Then ScrollView's scrollDirection size is same size as Content size (All children size).
If we, for example, have four worker-processes and 37 taskels, there will be idling workers even with chunksize=1, just because n_workers=4 is not a divisor of 37. The remainder of dividing 37 / 4 is 1. This single remaining taskel will have to be processed by a sole worker, while the remaining three are idling.
But Why ScrollView scrollDirection is need to switch between these 02 sizes ???
Likewise, there will still be one idling worker with 39 taskels, how you can see pictured below.
Reason is ScrollView's parent constraints.
If ScrollView's parent give an Tight or Loose constraint , Then your ScrollView's scrollDirection size is same as its parent size. [shrinkWrap : false].
When you compare the upper Parallel Schedule for chunksize=1 with the below version for chunksize=3, you will notice that the upper Parallel Schedule is smaller, the timeline on the x-axis shorter. It should become obvious now, how bigger chunksizes unexpectedly also can lead to increased overall computation times, even for Dense Scenarios.
If ScrollView's parent give an Unbound constraint , Then your ScrollView's scrollDirection size must need to be same as its Content size. [shrinkWrap : true]. Otherwise it will give an unbound height runtime exception
But why not just use the length of the x-axis for efficiency calculations?
By the way, you can add this property to other widgets such as RisedButton to shrinks the tap target size to the minimum provided by the Material specification.