|
12 | 12 |
|
13 | 13 | #define NumberOfSections 10 |
14 | 14 | #define NumberOfRowsPerSection 20 |
15 | | -#define NumberOfReloadIterations 50 |
| 15 | +#define NumberOfReloadIterations 250 |
16 | 16 |
|
17 | 17 | @interface ASTestTableView : ASTableView |
18 | 18 | @property (atomic, copy) void (^willDeallocBlock)(ASTableView *tableView); |
@@ -155,28 +155,34 @@ - (void)testReloadData |
155 | 155 | [tableView reloadData]; |
156 | 156 |
|
157 | 157 | for (int i = 0; i < NumberOfReloadIterations; ++i) { |
158 | | - UITableViewRowAnimation rowAnimation = (arc4random_uniform(1) == 0 ? UITableViewRowAnimationMiddle : UITableViewRowAnimationNone); |
159 | | - |
160 | | - BOOL animatedScroll = (arc4random_uniform(1) == 0 ? YES : NO); |
161 | | - BOOL reloadRowsInsteadOfSections = (arc4random_uniform(1) == 0 ? YES : NO); |
162 | | - BOOL letRunloopProceed = (arc4random_uniform(1) == 0 ? YES : NO); |
163 | | - BOOL useBeginEndUpdates = (arc4random_uniform(2) == 0 ? YES : NO); |
| 158 | + UITableViewRowAnimation rowAnimation = (arc4random_uniform(2) == 0 ? UITableViewRowAnimationMiddle : UITableViewRowAnimationNone); |
| 159 | + BOOL animatedScroll = (arc4random_uniform(2) == 0 ? YES : NO); |
| 160 | + BOOL reloadRowsInsteadOfSections = (arc4random_uniform(2) == 0 ? YES : NO); |
| 161 | + NSTimeInterval runLoopDelay = ((arc4random_uniform(2) == 0) ? (1.0 / (1 + arc4random_uniform(500))) : 0); |
| 162 | + BOOL useBeginEndUpdates = (arc4random_uniform(3) == 0 ? YES : NO); |
| 163 | + |
| 164 | + // instrument our instrumentation ;) |
| 165 | + NSLog(@"Iteration %03d: %@|%@|%@|%@|%g", i, (rowAnimation == UITableViewRowAnimationNone) ? @"NONE " : @"MIDDLE", animatedScroll ? @"ASCR" : @" ", reloadRowsInsteadOfSections ? @"ROWS" : @"SECS", useBeginEndUpdates ? @"BEGEND" : @" ", runLoopDelay); |
164 | 166 |
|
165 | 167 | if (useBeginEndUpdates) { |
166 | 168 | [tableView beginUpdates]; |
167 | 169 | } |
168 | 170 |
|
169 | 171 | if (reloadRowsInsteadOfSections) { |
170 | | - [tableView reloadRowsAtIndexPaths:[self randomIndexPathsExisting:YES] withRowAnimation:rowAnimation]; |
| 172 | + NSArray *indexPaths = [self randomIndexPathsExisting:YES]; |
| 173 | + //NSLog(@"reloading rows: %@", indexPaths); |
| 174 | + [tableView reloadRowsAtIndexPaths:indexPaths withRowAnimation:rowAnimation]; |
171 | 175 | } else { |
172 | | - [tableView reloadSections:[self randomIndexSet] withRowAnimation:rowAnimation]; |
| 176 | + NSIndexSet *sections = [self randomIndexSet]; |
| 177 | + //NSLog(@"reloading sections: %@", sections); |
| 178 | + [tableView reloadSections:sections withRowAnimation:rowAnimation]; |
173 | 179 | } |
174 | 180 |
|
175 | 181 | [tableView setContentOffset:CGPointMake(0, arc4random_uniform(tableView.contentSize.height - tableView.bounds.size.height)) animated:animatedScroll]; |
176 | 182 |
|
177 | | - if (letRunloopProceed) { |
| 183 | + if (runLoopDelay > 0) { |
178 | 184 | // Run other stuff on the main queue for between 2ms and 1000ms. |
179 | | - [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:(1 / (1 + arc4random_uniform(500)))]]; |
| 185 | + [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:runLoopDelay]]; |
180 | 186 | } |
181 | 187 |
|
182 | 188 | if (useBeginEndUpdates) { |
|
0 commit comments