github.com/gogf/gf/v2@v2.7.4/debug/gdebug/gdebug_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 gdebug
    10  
    11  import (
    12  	"runtime"
    13  	"runtime/debug"
    14  	"testing"
    15  )
    16  
    17  func Benchmark_BinVersion(b *testing.B) {
    18  	for i := 0; i < b.N; i++ {
    19  		BinVersion()
    20  	}
    21  }
    22  
    23  func Benchmark_BinVersionMd5(b *testing.B) {
    24  	for i := 0; i < b.N; i++ {
    25  		BinVersionMd5()
    26  	}
    27  }
    28  
    29  func Benchmark_RuntimeCaller(b *testing.B) {
    30  	for i := 0; i < b.N; i++ {
    31  		runtime.Caller(0)
    32  	}
    33  }
    34  
    35  func Benchmark_RuntimeFuncForPC(b *testing.B) {
    36  	for i := 0; i < b.N; i++ {
    37  		runtime.FuncForPC(11010101)
    38  	}
    39  }
    40  
    41  func Benchmark_callerFromIndex(b *testing.B) {
    42  	for i := 0; i < b.N; i++ {
    43  		callerFromIndex(nil)
    44  	}
    45  }
    46  
    47  func Benchmark_Stack(b *testing.B) {
    48  	for i := 0; i < b.N; i++ {
    49  		Stack()
    50  	}
    51  }
    52  
    53  func Benchmark_StackOfStdlib(b *testing.B) {
    54  	for i := 0; i < b.N; i++ {
    55  		debug.Stack()
    56  	}
    57  }
    58  
    59  func Benchmark_StackWithFilter(b *testing.B) {
    60  	for i := 0; i < b.N; i++ {
    61  		StackWithFilter([]string{"test"})
    62  	}
    63  }
    64  
    65  func Benchmark_Caller(b *testing.B) {
    66  	for i := 0; i < b.N; i++ {
    67  		Caller()
    68  	}
    69  }
    70  
    71  func Benchmark_CallerWithFilter(b *testing.B) {
    72  	for i := 0; i < b.N; i++ {
    73  		CallerWithFilter([]string{"test"})
    74  	}
    75  }
    76  
    77  func Benchmark_CallerFilePath(b *testing.B) {
    78  	for i := 0; i < b.N; i++ {
    79  		CallerFilePath()
    80  	}
    81  }
    82  
    83  func Benchmark_CallerDirectory(b *testing.B) {
    84  	for i := 0; i < b.N; i++ {
    85  		CallerDirectory()
    86  	}
    87  }
    88  
    89  func Benchmark_CallerFileLine(b *testing.B) {
    90  	for i := 0; i < b.N; i++ {
    91  		CallerFileLine()
    92  	}
    93  }
    94  
    95  func Benchmark_CallerFileLineShort(b *testing.B) {
    96  	for i := 0; i < b.N; i++ {
    97  		CallerFileLineShort()
    98  	}
    99  }
   100  
   101  func Benchmark_CallerFunction(b *testing.B) {
   102  	for i := 0; i < b.N; i++ {
   103  		CallerFunction()
   104  	}
   105  }
   106  
   107  func Benchmark_CallerPackage(b *testing.B) {
   108  	for i := 0; i < b.N; i++ {
   109  		CallerPackage()
   110  	}
   111  }