Server : LiteSpeed System : Linux in-mum-web1333.main-hosting.eu 4.18.0-553.37.1.lve.el8.x86_64 #1 SMP Mon Feb 10 22:45:17 UTC 2025 x86_64 User : u141265441 ( 141265441) PHP Version : 8.4.3 Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail Directory : /proc/self/root/opt/golang/1.19.4/src/cmd/compile/internal/test/ |
// Copyright 2020 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package test
import "testing"
var globl int64
var globl32 int32
func BenchmarkLoadAdd(b *testing.B) {
x := make([]int64, 1024)
y := make([]int64, 1024)
for i := 0; i < b.N; i++ {
var s int64
for i := range x {
s ^= x[i] + y[i]
}
globl = s
}
}
// Added for ppc64 extswsli on power9
func BenchmarkExtShift(b *testing.B) {
x := make([]int32, 1024)
for i := 0; i < b.N; i++ {
var s int64
for i := range x {
s ^= int64(x[i]+32) * 8
}
globl = s
}
}
func BenchmarkModify(b *testing.B) {
a := make([]int64, 1024)
v := globl
for i := 0; i < b.N; i++ {
for j := range a {
a[j] += v
}
}
}
func BenchmarkMullImm(b *testing.B) {
x := make([]int32, 1024)
for i := 0; i < b.N; i++ {
var s int32
for i := range x {
s += x[i] * 100
}
globl32 = s
}
}
func BenchmarkConstModify(b *testing.B) {
a := make([]int64, 1024)
for i := 0; i < b.N; i++ {
for j := range a {
a[j] += 3
}
}
}
func BenchmarkBitSet(b *testing.B) {
const N = 64 * 8
a := make([]uint64, N/64)
for i := 0; i < b.N; i++ {
for j := uint64(0); j < N; j++ {
a[j/64] |= 1 << (j % 64)
}
}
}
func BenchmarkBitClear(b *testing.B) {
const N = 64 * 8
a := make([]uint64, N/64)
for i := 0; i < b.N; i++ {
for j := uint64(0); j < N; j++ {
a[j/64] &^= 1 << (j % 64)
}
}
}
func BenchmarkBitToggle(b *testing.B) {
const N = 64 * 8
a := make([]uint64, N/64)
for i := 0; i < b.N; i++ {
for j := uint64(0); j < N; j++ {
a[j/64] ^= 1 << (j % 64)
}
}
}
func BenchmarkBitSetConst(b *testing.B) {
const N = 64
a := make([]uint64, N)
for i := 0; i < b.N; i++ {
for j := range a {
a[j] |= 1 << 37
}
}
}
func BenchmarkBitClearConst(b *testing.B) {
const N = 64
a := make([]uint64, N)
for i := 0; i < b.N; i++ {
for j := range a {
a[j] &^= 1 << 37
}
}
}
func BenchmarkBitToggleConst(b *testing.B) {
const N = 64
a := make([]uint64, N)
for i := 0; i < b.N; i++ {
for j := range a {
a[j] ^= 1 << 37
}
}
}