v8.run/go/exp@v0.0.26-0.20230226010534-afcdbd3f782d/util/noescape/noescape_test.go (about) 1 package noescape 2 3 import ( 4 "testing" 5 ) 6 7 func BenchmarkNoEscapeBytes(b *testing.B) { 8 b.RunParallel(func(p *testing.PB) { 9 var b [8]byte 10 t := b[:] 11 var v []byte 12 for p.Next() { 13 v = Bytes(&t) 14 } 15 EscapeBytes(v) 16 }) 17 } 18 19 func BenchmarkNoEscapeWrite(b *testing.B) { 20 b.RunParallel(func(p *testing.PB) { 21 for p.Next() { 22 var b [256]byte 23 t := b[:] 24 Write(blackholeIO, t) 25 } 26 }) 27 } 28 29 func BenchmarkNoEscapeRead(b *testing.B) { 30 b.RunParallel(func(p *testing.PB) { 31 for p.Next() { 32 var b [256]byte 33 t := b[:] 34 Read(blackholeIO, t) 35 } 36 }) 37 } 38 39 func BenchmarkWrite(b *testing.B) { 40 b.RunParallel(func(p *testing.PB) { 41 for p.Next() { 42 var b [256]byte 43 t := b[:] 44 blackholeIO.Write(t) 45 } 46 }) 47 } 48 49 func BenchmarkRead(b *testing.B) { 50 b.RunParallel(func(p *testing.PB) { 51 for p.Next() { 52 var b [256]byte 53 t := b[:] 54 blackholeIO.Read(t) 55 } 56 }) 57 }