Source file src/cmd/compile/internal/ssa/bench_test.go

     1  // Copyright 2020 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  package ssa
     5  
     6  import (
     7  	"math/rand"
     8  	"testing"
     9  )
    10  
    11  var d int
    12  
    13  //go:noinline
    14  func fn(a, b int) bool {
    15  	c := false
    16  	if a > 0 {
    17  		if b < 0 {
    18  			d = d + 1
    19  		}
    20  		c = true
    21  	}
    22  	return c
    23  }
    24  
    25  func BenchmarkPhioptPass(b *testing.B) {
    26  	for i := 0; i < b.N; i++ {
    27  		a := rand.Perm(i/10 + 10)
    28  		for i := 1; i < len(a)/2; i++ {
    29  			fn(a[i]-a[i-1], a[i+len(a)/2-2]-a[i+len(a)/2-1])
    30  		}
    31  	}
    32  }
    33  

View as plain text