Skip to content

Latest commit

 

History

History
26 lines (22 loc) · 408 Bytes

File metadata and controls

26 lines (22 loc) · 408 Bytes

Go To Memory

package main_test

import "testing"

func BenchmarkAssignmentIndirect(b *testing.B) {
	type X struct {
		p *int
	}
	for i := 0; i < b.N; i++ {
		// go test -bench=. >>> 0.2588 ns/op
		var i1 int
		x1 := &X{
			p: &i1,
		}
		_ = x1

		// go test -bench=. >>> 12.36 ns/op
		// var i2 int
		// x2 := &X{}
		// x2.p = &i2
	}
}