File tree Expand file tree Collapse file tree 1 file changed +4
-0
lines changed Expand file tree Collapse file tree 1 file changed +4
-0
lines changed Original file line number Diff line number Diff line change 77
88// Test the performance of the standard conversion string()
99func Benchmark_StdFromBytes (b * testing.B ) {
10+ b .ReportAllocs ()
1011 x := []byte ("Hello world! Hello world! Hello world!" )
1112 for i := 0 ; i < b .N ; i ++ {
1213 _ = string (x )
@@ -15,6 +16,7 @@ func Benchmark_StdFromBytes(b *testing.B) {
1516
1617// Test the performance of strong conversion []byte to string
1718func Benchmark_FromBytes (b * testing.B ) {
19+ b .ReportAllocs ()
1820 x := []byte ("Hello world! Hello world! Hello world!" )
1921 for i := 0 ; i < b .N ; i ++ {
2022 _ = FromBytes (x )
@@ -23,6 +25,7 @@ func Benchmark_FromBytes(b *testing.B) {
2325
2426// Test the performance of standard conversion []byte
2527func Benchmark_StdToBytes (b * testing.B ) {
28+ b .ReportAllocs ()
2629 x := "Hello world! Hello world! Hello world!"
2730 for i := 0 ; i < b .N ; i ++ {
2831 _ = []byte (x )
@@ -31,6 +34,7 @@ func Benchmark_StdToBytes(b *testing.B) {
3134
3235// Test the performance of strong conversion string to []byte
3336func Benchmark_ToBytes (b * testing.B ) {
37+ b .ReportAllocs ()
3438 x := "Hello world! Hello world! Hello world!"
3539 for i := 0 ; i < b .N ; i ++ {
3640 _ = ToBytes (x )
You can’t perform that action at this time.
0 commit comments