github.com/gogf/gf/v2@v2.7.4/util/gutil/gutil_z_bench_test.go (about)

     1  // Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
     2  //
     3  // This Source Code Form is subject to the terms of the MIT License.
     4  // If a copy of the MIT was not distributed with this file,
     5  // You can obtain one at https://github.com/gogf/gf.
     6  
     7  // go test *.go -bench=".*" -benchmem
     8  
     9  package gutil
    10  
    11  import (
    12  	"context"
    13  	"testing"
    14  )
    15  
    16  var (
    17  	m1 = map[string]interface{}{
    18  		"k1": "v1",
    19  	}
    20  	m2 = map[string]interface{}{
    21  		"k2": "v2",
    22  	}
    23  )
    24  
    25  func Benchmark_TryCatch(b *testing.B) {
    26  	ctx := context.TODO()
    27  	for i := 0; i < b.N; i++ {
    28  		TryCatch(ctx, func(ctx context.Context) {
    29  
    30  		}, func(ctx context.Context, err error) {
    31  
    32  		})
    33  	}
    34  }
    35  
    36  func Benchmark_MapMergeCopy(b *testing.B) {
    37  	for i := 0; i < b.N; i++ {
    38  		MapMergeCopy(m1, m2)
    39  	}
    40  }