...

Source file src/github.com/leodido/go-urn/performance_test.go

Documentation: github.com/leodido/go-urn

     1  package urn
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  )
     7  
     8  var benchs = []testCase{
     9  	urn2141OnlyTestCases[14],
    10  	urn2141OnlyTestCases[2],
    11  	urn2141OnlyTestCases[6],
    12  	urn2141OnlyTestCases[10],
    13  	urn2141OnlyTestCases[11],
    14  	urn2141OnlyTestCases[13],
    15  	urn2141OnlyTestCases[20],
    16  	urn2141OnlyTestCases[23],
    17  	urn2141OnlyTestCases[33],
    18  	urn2141OnlyTestCases[45],
    19  	urn2141OnlyTestCases[47],
    20  	urn2141OnlyTestCases[48],
    21  	urn2141OnlyTestCases[50],
    22  	urn2141OnlyTestCases[52],
    23  	urn2141OnlyTestCases[53],
    24  	urn2141OnlyTestCases[57],
    25  	urn2141OnlyTestCases[62],
    26  	urn2141OnlyTestCases[63],
    27  	urn2141OnlyTestCases[67],
    28  	urn2141OnlyTestCases[60],
    29  }
    30  
    31  // This is here to avoid compiler optimizations that
    32  // could remove the actual call we are benchmarking
    33  // during benchmarks
    34  var benchParseResult *URN
    35  
    36  func BenchmarkParse(b *testing.B) {
    37  	for ii, tt := range benchs {
    38  		tt := tt
    39  		outcome := (map[bool]string{true: "ok", false: "no"})[tt.ok]
    40  		b.Run(
    41  			fmt.Sprintf("%s/%02d/%s/", outcome, ii, rxpad(string(tt.in), 45)),
    42  			func(b *testing.B) {
    43  				for i := 0; i < b.N; i++ {
    44  					benchParseResult, _ = Parse(tt.in)
    45  				}
    46  			},
    47  		)
    48  	}
    49  }
    50  

View as plain text