@@ -193,12 +193,8 @@ fn allocate_many_size_aligns() {
193
193
#[ cfg( miri) ]
194
194
const ALIGN : Range < usize > = 1 ..4 ;
195
195
196
- #[ cfg( not( miri) ) ]
197
196
const STRATS : Range < usize > = 0 ..4 ;
198
197
199
- #[ cfg( miri) ]
200
- const STRATS : Range < usize > = 0 ..2 ;
201
-
202
198
let mut heap = new_heap ( ) ;
203
199
assert_eq ! ( heap. size( ) , 1000 ) ;
204
200
@@ -217,36 +213,45 @@ fn allocate_many_size_aligns() {
217
213
layout : Layout ,
218
214
}
219
215
216
+ // NOTE: Printing to the console SIGNIFICANTLY slows down miri.
217
+
220
218
for strat in STRATS {
221
219
for align in ALIGN {
222
220
for size in SIZE {
223
- println ! ( "=========================================================" ) ;
224
- println ! ( "Align: {}" , 1 << align) ;
225
- println ! ( "Size: {}" , size) ;
226
- println ! ( "Free Pattern: {}/0..4" , strat) ;
227
- println ! ( ) ;
221
+ #[ cfg( not( miri) ) ]
222
+ {
223
+ println ! ( "=========================================================" ) ;
224
+ println ! ( "Align: {}" , 1 << align) ;
225
+ println ! ( "Size: {}" , size) ;
226
+ println ! ( "Free Pattern: {}/0..4" , strat) ;
227
+ println ! ( ) ;
228
+ }
228
229
let mut allocs = vec ! [ ] ;
229
230
230
231
let layout = Layout :: from_size_align ( size, 1 << align) . unwrap ( ) ;
231
232
while let Ok ( alloc) = heap. allocate_first_fit ( layout) {
233
+ #[ cfg( not( miri) ) ]
232
234
heap. holes . debug ( ) ;
233
235
allocs. push ( Alloc { alloc, layout } ) ;
234
236
}
235
237
238
+ #[ cfg( not( miri) ) ]
236
239
println ! ( "Allocs: {} - {} bytes" , allocs. len( ) , allocs. len( ) * size) ;
237
240
238
241
match strat {
239
242
0 => {
240
243
// Forward
241
244
allocs. drain ( ..) . for_each ( |a| unsafe {
242
245
heap. deallocate ( a. alloc , a. layout ) ;
246
+ #[ cfg( not( miri) ) ]
243
247
heap. holes . debug ( ) ;
244
248
} ) ;
245
249
}
246
250
1 => {
247
251
// Backwards
248
252
allocs. drain ( ..) . rev ( ) . for_each ( |a| unsafe {
249
253
heap. deallocate ( a. alloc , a. layout ) ;
254
+ #[ cfg( not( miri) ) ]
250
255
heap. holes . debug ( ) ;
251
256
} ) ;
252
257
}
@@ -263,10 +268,12 @@ fn allocate_many_size_aligns() {
263
268
}
264
269
a. drain ( ..) . for_each ( |a| unsafe {
265
270
heap. deallocate ( a. alloc , a. layout ) ;
271
+ #[ cfg( not( miri) ) ]
266
272
heap. holes . debug ( ) ;
267
273
} ) ;
268
274
b. drain ( ..) . for_each ( |a| unsafe {
269
275
heap. deallocate ( a. alloc , a. layout ) ;
276
+ #[ cfg( not( miri) ) ]
270
277
heap. holes . debug ( ) ;
271
278
} ) ;
272
279
}
@@ -283,22 +290,27 @@ fn allocate_many_size_aligns() {
283
290
}
284
291
a. drain ( ..) . for_each ( |a| unsafe {
285
292
heap. deallocate ( a. alloc , a. layout ) ;
293
+ #[ cfg( not( miri) ) ]
286
294
heap. holes . debug ( ) ;
287
295
} ) ;
288
296
b. drain ( ..) . for_each ( |a| unsafe {
289
297
heap. deallocate ( a. alloc , a. layout ) ;
298
+ #[ cfg( not( miri) ) ]
290
299
heap. holes . debug ( ) ;
291
300
} ) ;
292
301
}
293
302
_ => panic ! ( ) ,
294
303
}
295
304
305
+ #[ cfg( not( miri) ) ]
296
306
println ! ( "MAX CHECK" ) ;
297
307
298
308
let full = heap. allocate_first_fit ( max_alloc) . unwrap ( ) ;
299
309
unsafe {
300
310
heap. deallocate ( full, max_alloc) ;
301
311
}
312
+
313
+ #[ cfg( not( miri) ) ]
302
314
println ! ( ) ;
303
315
}
304
316
}
0 commit comments