github.com/marcosxz/kit@v0.0.0-20191211013450-e72ea58dfd46/reflect_test.go (about)

     1  package kit
     2  
     3  import (
     4  	"testing"
     5  )
     6  
     7  var testCallFunction = func(arg1 int, arg2 bool) (int, bool) { return arg1, arg2 }
     8  
     9  func BenchmarkCallFunction(b *testing.B) {
    10  
    11  	b.ReportAllocs()
    12  
    13  	for i := 0; i < 2; i++ {
    14  		if results, err := CallFunction(testCallFunction, 1, true); err != nil {
    15  			b.Error(err)
    16  			b.FailNow()
    17  		} else {
    18  			for _, result := range results {
    19  				b.Log(result)
    20  			}
    21  		}
    22  	}
    23  }