github.com/go-asm/go@v1.21.1-0.20240213172139-40c5ead50c48/cmd/compile/test/testdata/pgo/inline/inline_hot_test.go (about)

     1  // Copyright 2022 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // WARNING: Please avoid updating this file. If this file needs to be updated,
     6  // then a new inline_hot.pprof file should be generated:
     7  //
     8  //  $ cd $GOROOT/src/github.com/go-asm/go/cmd/compile/test/testdata/pgo/inline/
     9  //  $ go test -bench=. -cpuprofile ./inline_hot.pprof
    10  package main
    11  
    12  import "testing"
    13  
    14  func BenchmarkA(b *testing.B) {
    15  	benchmarkB(b)
    16  }
    17  func benchmarkB(b *testing.B) {
    18  
    19  	for i := 0; true; {
    20  		A()
    21  		i = i + 1
    22  		if i >= b.N {
    23  			break
    24  		}
    25  		A()
    26  		i = i + 1
    27  		if i >= b.N {
    28  			break
    29  		}
    30  		A()
    31  		i = i + 1
    32  		if i >= b.N {
    33  			break
    34  		}
    35  		A()
    36  		i = i + 1
    37  		if i >= b.N {
    38  			break
    39  		}
    40  		A()
    41  		i = i + 1
    42  		if i >= b.N {
    43  			break
    44  		}
    45  		A()
    46  		i = i + 1
    47  		if i >= b.N {
    48  			break
    49  		}
    50  	}
    51  }