arrayofarray

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

Appending elements to an array of array

Adding a element to an array is done using append. The array is defined as:

  • [][]int which is always the underlying type
  • []t
  • tt where a method is used

Using a method is the most efficient even if difference can be small.

src>go test -bench=. ./arrayofarray

Results

go version go1.12 windows/amd64

add one cell (inc == 1)

BenchmarkUpdateArray-4          10000000               165 ns/op
BenchmarkUpdateArrayType-4      20000000               130 ns/op
BenchmarkUpdateArrayMethod-4    20000000               113 ns/op

add 10 cells (inc == 10)

BenchmarkUpdateArray-4           1000000              1751 ns/op
BenchmarkUpdateArrayType-4       1000000              1297 ns/op
BenchmarkUpdateArrayMethod-4     1000000              1008 ns/op
PASS

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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