Skip to content

Commit c9f639c

Browse files
committed
added reposrt allocs into benchmarks
1 parent dcc97e0 commit c9f639c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

internal/xstring/convert_bench_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77

88
// Test the performance of the standard conversion string()
99
func 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
1718
func 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
2527
func 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
3336
func 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)

0 commit comments

Comments
 (0)