github.com/geniusesgroup/libgo@v0.0.0-20220713101832-828057a9d3d4/binary/le_bench_test.go (about)

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