github.com/GeniusesGroup/libgo@v0.0.0-20220929090155-5ff932cb408e/binary/be_bench_test.go (about)

     1  package binary
     2  
     3  import "testing"
     4  
     5  func BenchmarkBigEndian_PutUint16(b *testing.B) {
     6  	for i := 0; i < b.N; i++ {
     7  		BigEndian.PutUint16(putbuf[:2], uint16(i))
     8  	}
     9  }
    10  
    11  func BenchmarkBigEndian_PutUint32(b *testing.B) {
    12  	for i := 0; i < b.N; i++ {
    13  		BigEndian.PutUint32(putbuf[:4], uint32(i))
    14  	}
    15  }
    16  
    17  func BenchmarkBigEndian_PutUint64(b *testing.B) {
    18  	for i := 0; i < b.N; i++ {
    19  		BigEndian.PutUint64(putbuf, uint64(i))
    20  	}
    21  }
    22  
    23  func BenchmarkBigEndian_Uint16(b *testing.B) {
    24  	for i := 0; i < b.N; i++ {
    25  		u16 = BigEndian.Uint16(big[2:4])
    26  	}
    27  }
    28  
    29  func BenchmarkBigEndian_Uint32(b *testing.B) {
    30  	for i := 0; i < b.N; i++ {
    31  		u32 = BigEndian.Uint32(big[4:8])
    32  	}
    33  }
    34  
    35  func BenchmarkBigEndian_Uint64(b *testing.B) {
    36  	for i := 0; i < b.N; i++ {
    37  		u64 = BigEndian.Uint64(big[8:])
    38  	}
    39  }