File: benchDot_test.go

package info (click to toggle)
golang-gonum-v1-gonum 0.15.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 18,792 kB
  • sloc: asm: 6,252; fortran: 5,271; sh: 377; ruby: 211; makefile: 98
file content (57 lines) | stat: -rw-r--r-- 1,388 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright ©2017 The Gonum 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 c64

import (
	"fmt"
	"testing"
)

var benchSink complex64

func BenchmarkDotUnitary(t *testing.B) {
	for _, tst := range []struct {
		name string
		f    func(x, y []complex64) complex64
	}{
		{"DotcUnitary", DotcUnitary},
		{"DotuUnitary", DotuUnitary},
	} {
		for _, v := range []int64{1, 2, 3, 4, 5, 10, 100, 1e3, 5e3, 1e4, 5e4} {
			t.Run(fmt.Sprintf("%s-%d", tst.name, v), func(b *testing.B) {
				x, y := x[:v], y[:v]
				b.SetBytes(128 * v)
				for i := 0; i < b.N; i++ {
					benchSink = tst.f(x, y)
				}
			})
		}
	}
}

func BenchmarkDotInc(t *testing.B) {
	for _, tst := range []struct {
		name string
		f    func(x, y []complex64, n, incX, incY, ix, iy uintptr) complex64
	}{
		{"DotcInc", DotcInc},
		{"DotuInc", DotuInc},
	} {
		for _, ln := range []int{1, 2, 3, 4, 5, 10, 100, 1e3, 5e3, 1e4, 5e4} {
			for _, inc := range []int{1, 2, 4, 10, -1, -2, -4, -10} {
				t.Run(fmt.Sprintf("%s-%d-inc%d", tst.name, ln, inc), func(b *testing.B) {
					b.SetBytes(int64(128 * ln))
					var idx int
					if inc < 0 {
						idx = (-ln + 1) * inc
					}
					for i := 0; i < b.N; i++ {
						benchSink = tst.f(x, y, uintptr(ln), uintptr(inc), uintptr(inc), uintptr(idx), uintptr(idx))
					}
				})
			}
		}
	}
}