Skip to content

math: make benchmark iterations more data-dependent #33441

@smasher164

Description

@smasher164

As discussed in CL 127458, benchmarks should be updated to make each iteration dependent on the result of the previous. This reduces the chance of work done in the loop being optimized away, as well feeding the benchmarks a larger input space. For instance, the FMA benchmark was changed from

func BenchmarkFma(b *testing.B) {
	x := 0.0
	for i := 0; i < b.N; i++ {
		x = Fma(E, Pi, Phi)
	}
	GlobalF = x
}

to

func BenchmarkFma(b *testing.B) {
	x := 0.0
	for i := 0; i < b.N; i++ {
		x = Fma(E, Pi, x)
	}
	GlobalF = x
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions