github.com/gagliardetto/golang-go@v0.0.0-20201020153340-53909ea70814/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 boolres bool
    12  
    13  var i64res int64
    14  
    15  func BenchmarkDivconstI64(b *testing.B) {
    16  	for i := 0; i < b.N; i++ {
    17  		i64res = int64(i) / 7
    18  	}
    19  }
    20  
    21  func BenchmarkModconstI64(b *testing.B) {
    22  	for i := 0; i < b.N; i++ {
    23  		i64res = int64(i) % 7
    24  	}
    25  }
    26  
    27  func BenchmarkDivisiblePow2constI64(b *testing.B) {
    28  	for i := 0; i < b.N; i++ {
    29  		boolres = int64(i)%16 == 0
    30  	}
    31  }
    32  func BenchmarkDivisibleconstI64(b *testing.B) {
    33  	for i := 0; i < b.N; i++ {
    34  		boolres = int64(i)%7 == 0
    35  	}
    36  }
    37  
    38  func BenchmarkDivisibleWDivconstI64(b *testing.B) {
    39  	for i := 0; i < b.N; i++ {
    40  		i64res = int64(i) / 7
    41  		boolres = int64(i)%7 == 0
    42  	}
    43  }
    44  
    45  var u64res uint64
    46  
    47  func BenchmarkDivconstU64(b *testing.B) {
    48  	for i := 0; i < b.N; i++ {
    49  		u64res = uint64(i) / 7
    50  	}
    51  }
    52  
    53  func BenchmarkModconstU64(b *testing.B) {
    54  	for i := 0; i < b.N; i++ {
    55  		u64res = uint64(i) % 7
    56  	}
    57  }
    58  
    59  func BenchmarkDivisibleconstU64(b *testing.B) {
    60  	for i := 0; i < b.N; i++ {
    61  		boolres = uint64(i)%7 == 0
    62  	}
    63  }
    64  
    65  func BenchmarkDivisibleWDivconstU64(b *testing.B) {
    66  	for i := 0; i < b.N; i++ {
    67  		u64res = uint64(i) / 7
    68  		boolres = uint64(i)%7 == 0
    69  	}
    70  }
    71  
    72  var i32res int32
    73  
    74  func BenchmarkDivconstI32(b *testing.B) {
    75  	for i := 0; i < b.N; i++ {
    76  		i32res = int32(i) / 7
    77  	}
    78  }
    79  
    80  func BenchmarkModconstI32(b *testing.B) {
    81  	for i := 0; i < b.N; i++ {
    82  		i32res = int32(i) % 7
    83  	}
    84  }
    85  
    86  func BenchmarkDivisiblePow2constI32(b *testing.B) {
    87  	for i := 0; i < b.N; i++ {
    88  		boolres = int32(i)%16 == 0
    89  	}
    90  }
    91  
    92  func BenchmarkDivisibleconstI32(b *testing.B) {
    93  	for i := 0; i < b.N; i++ {
    94  		boolres = int32(i)%7 == 0
    95  	}
    96  }
    97  
    98  func BenchmarkDivisibleWDivconstI32(b *testing.B) {
    99  	for i := 0; i < b.N; i++ {
   100  		i32res = int32(i) / 7
   101  		boolres = int32(i)%7 == 0
   102  	}
   103  }
   104  
   105  var u32res uint32
   106  
   107  func BenchmarkDivconstU32(b *testing.B) {
   108  	for i := 0; i < b.N; i++ {
   109  		u32res = uint32(i) / 7
   110  	}
   111  }
   112  
   113  func BenchmarkModconstU32(b *testing.B) {
   114  	for i := 0; i < b.N; i++ {
   115  		u32res = uint32(i) % 7
   116  	}
   117  }
   118  
   119  func BenchmarkDivisibleconstU32(b *testing.B) {
   120  	for i := 0; i < b.N; i++ {
   121  		boolres = uint32(i)%7 == 0
   122  	}
   123  }
   124  
   125  func BenchmarkDivisibleWDivconstU32(b *testing.B) {
   126  	for i := 0; i < b.N; i++ {
   127  		u32res = uint32(i) / 7
   128  		boolres = uint32(i)%7 == 0
   129  	}
   130  }
   131  
   132  var i16res int16
   133  
   134  func BenchmarkDivconstI16(b *testing.B) {
   135  	for i := 0; i < b.N; i++ {
   136  		i16res = int16(i) / 7
   137  	}
   138  }
   139  
   140  func BenchmarkModconstI16(b *testing.B) {
   141  	for i := 0; i < b.N; i++ {
   142  		i16res = int16(i) % 7
   143  	}
   144  }
   145  
   146  func BenchmarkDivisiblePow2constI16(b *testing.B) {
   147  	for i := 0; i < b.N; i++ {
   148  		boolres = int16(i)%16 == 0
   149  	}
   150  }
   151  
   152  func BenchmarkDivisibleconstI16(b *testing.B) {
   153  	for i := 0; i < b.N; i++ {
   154  		boolres = int16(i)%7 == 0
   155  	}
   156  }
   157  
   158  func BenchmarkDivisibleWDivconstI16(b *testing.B) {
   159  	for i := 0; i < b.N; i++ {
   160  		i16res = int16(i) / 7
   161  		boolres = int16(i)%7 == 0
   162  	}
   163  }
   164  
   165  var u16res uint16
   166  
   167  func BenchmarkDivconstU16(b *testing.B) {
   168  	for i := 0; i < b.N; i++ {
   169  		u16res = uint16(i) / 7
   170  	}
   171  }
   172  
   173  func BenchmarkModconstU16(b *testing.B) {
   174  	for i := 0; i < b.N; i++ {
   175  		u16res = uint16(i) % 7
   176  	}
   177  }
   178  
   179  func BenchmarkDivisibleconstU16(b *testing.B) {
   180  	for i := 0; i < b.N; i++ {
   181  		boolres = uint16(i)%7 == 0
   182  	}
   183  }
   184  
   185  func BenchmarkDivisibleWDivconstU16(b *testing.B) {
   186  	for i := 0; i < b.N; i++ {
   187  		u16res = uint16(i) / 7
   188  		boolres = uint16(i)%7 == 0
   189  	}
   190  }
   191  
   192  var i8res int8
   193  
   194  func BenchmarkDivconstI8(b *testing.B) {
   195  	for i := 0; i < b.N; i++ {
   196  		i8res = int8(i) / 7
   197  	}
   198  }
   199  
   200  func BenchmarkModconstI8(b *testing.B) {
   201  	for i := 0; i < b.N; i++ {
   202  		i8res = int8(i) % 7
   203  	}
   204  }
   205  
   206  func BenchmarkDivisiblePow2constI8(b *testing.B) {
   207  	for i := 0; i < b.N; i++ {
   208  		boolres = int8(i)%16 == 0
   209  	}
   210  }
   211  
   212  func BenchmarkDivisibleconstI8(b *testing.B) {
   213  	for i := 0; i < b.N; i++ {
   214  		boolres = int8(i)%7 == 0
   215  	}
   216  }
   217  
   218  func BenchmarkDivisibleWDivconstI8(b *testing.B) {
   219  	for i := 0; i < b.N; i++ {
   220  		i8res = int8(i) / 7
   221  		boolres = int8(i)%7 == 0
   222  	}
   223  }
   224  
   225  var u8res uint8
   226  
   227  func BenchmarkDivconstU8(b *testing.B) {
   228  	for i := 0; i < b.N; i++ {
   229  		u8res = uint8(i) / 7
   230  	}
   231  }
   232  
   233  func BenchmarkModconstU8(b *testing.B) {
   234  	for i := 0; i < b.N; i++ {
   235  		u8res = uint8(i) % 7
   236  	}
   237  }
   238  
   239  func BenchmarkDivisibleconstU8(b *testing.B) {
   240  	for i := 0; i < b.N; i++ {
   241  		boolres = uint8(i)%7 == 0
   242  	}
   243  }
   244  
   245  func BenchmarkDivisibleWDivconstU8(b *testing.B) {
   246  	for i := 0; i < b.N; i++ {
   247  		u8res = uint8(i) / 7
   248  		boolres = uint8(i)%7 == 0
   249  	}
   250  }