github.com/mangodowner/go-gm@v0.0.0-20180818020936-8baa2bd4408c/src/cmd/compile/internal/test/divconst_test.go (about)

     1  // Copyright 2016 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  package test
     6  
     7  import (
     8  	"testing"
     9  )
    10  
    11  var i64res int64
    12  
    13  func BenchmarkDivconstI64(b *testing.B) {
    14  	for i := 0; i < b.N; i++ {
    15  		i64res = int64(i) / 7
    16  	}
    17  }
    18  
    19  var u64res uint64
    20  
    21  func BenchmarkDivconstU64(b *testing.B) {
    22  	for i := 0; i < b.N; i++ {
    23  		u64res = uint64(i) / 7
    24  	}
    25  }
    26  
    27  var i32res int32
    28  
    29  func BenchmarkDivconstI32(b *testing.B) {
    30  	for i := 0; i < b.N; i++ {
    31  		i32res = int32(i) / 7
    32  	}
    33  }
    34  
    35  var u32res uint32
    36  
    37  func BenchmarkDivconstU32(b *testing.B) {
    38  	for i := 0; i < b.N; i++ {
    39  		u32res = uint32(i) / 7
    40  	}
    41  }
    42  
    43  var i16res int16
    44  
    45  func BenchmarkDivconstI16(b *testing.B) {
    46  	for i := 0; i < b.N; i++ {
    47  		i16res = int16(i) / 7
    48  	}
    49  }
    50  
    51  var u16res uint16
    52  
    53  func BenchmarkDivconstU16(b *testing.B) {
    54  	for i := 0; i < b.N; i++ {
    55  		u16res = uint16(i) / 7
    56  	}
    57  }
    58  
    59  var i8res int8
    60  
    61  func BenchmarkDivconstI8(b *testing.B) {
    62  	for i := 0; i < b.N; i++ {
    63  		i8res = int8(i) / 7
    64  	}
    65  }
    66  
    67  var u8res uint8
    68  
    69  func BenchmarkDivconstU8(b *testing.B) {
    70  	for i := 0; i < b.N; i++ {
    71  		u8res = uint8(i) / 7
    72  	}
    73  }