forloops

package
v0.0.0-...-b91b1e7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 24, 2019 License: BSD-2-Clause Imports: 0 Imported by: 0

README

For loops should use a local var

For loop construction is very optimized in Go and for loops are everywhere.

The most efficient loop is using a locally defined variable.

src>go test -bench=. ./forbreak

Results

go version go1.12 windows/amd64

BenchmarkForGlobalVar-4           500000              2720 ns/op
BenchmarkForLocalVar-4           3000000               567 ns/op
PASS   

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ForGlobalVar

func ForGlobalVar() (res int)

func ForLocalVar

func ForLocalVar() (res int)

Effect of global var on for loop

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL