File tree Expand file tree Collapse file tree 1 file changed +5
-17
lines changed Expand file tree Collapse file tree 1 file changed +5
-17
lines changed Original file line number Diff line number Diff line change @@ -318,59 +318,47 @@ func TestArenaCollision(t *testing.T) {
318
318
}
319
319
}
320
320
321
- var mallocSink uintptr
322
-
323
321
func BenchmarkMalloc8 (b * testing.B ) {
324
- var x uintptr
325
322
for i := 0 ; i < b .N ; i ++ {
326
323
p := new (int64 )
327
- x ^= uintptr ( unsafe . Pointer ( p ) )
324
+ Escape ( p )
328
325
}
329
- mallocSink = x
330
326
}
331
327
332
328
func BenchmarkMalloc16 (b * testing.B ) {
333
- var x uintptr
334
329
for i := 0 ; i < b .N ; i ++ {
335
330
p := new ([2 ]int64 )
336
- x ^= uintptr ( unsafe . Pointer ( p ) )
331
+ Escape ( p )
337
332
}
338
- mallocSink = x
339
333
}
340
334
341
335
func BenchmarkMallocTypeInfo8 (b * testing.B ) {
342
- var x uintptr
343
336
for i := 0 ; i < b .N ; i ++ {
344
337
p := new (struct {
345
338
p [8 / unsafe .Sizeof (uintptr (0 ))]* int
346
339
})
347
- x ^= uintptr ( unsafe . Pointer ( p ) )
340
+ Escape ( p )
348
341
}
349
- mallocSink = x
350
342
}
351
343
352
344
func BenchmarkMallocTypeInfo16 (b * testing.B ) {
353
- var x uintptr
354
345
for i := 0 ; i < b .N ; i ++ {
355
346
p := new (struct {
356
347
p [16 / unsafe .Sizeof (uintptr (0 ))]* int
357
348
})
358
- x ^= uintptr ( unsafe . Pointer ( p ) )
349
+ Escape ( p )
359
350
}
360
- mallocSink = x
361
351
}
362
352
363
353
type LargeStruct struct {
364
354
x [16 ][]byte
365
355
}
366
356
367
357
func BenchmarkMallocLargeStruct (b * testing.B ) {
368
- var x uintptr
369
358
for i := 0 ; i < b .N ; i ++ {
370
359
p := make ([]LargeStruct , 2 )
371
- x ^= uintptr ( unsafe . Pointer ( & p [ 0 ]) )
360
+ Escape ( p )
372
361
}
373
- mallocSink = x
374
362
}
375
363
376
364
var n = flag .Int ("n" , 1000 , "number of goroutines" )
You can’t perform that action at this time.
0 commit comments