codewars

package
v0.0.0-...-9a25d2e Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2022 License: MIT Imports: 0 Imported by: 0

README

Codewars problems

Array Diff

go test -bench=. ./...  | benchgraph # Modified version of `CodingBerg/benchgraph` https://github.com/codingberg/benchgraph/pull/4

Bencmark result: http://benchgraph.codingberg.com/5n

Base on benchmarking Include solution is growing faster than using Map. If arrays have small size, than it is ok to use Include approach.

10 items:

BenchmarkArrayDiff/ArrayDiffMap_10-4             1000000              1004 ns/op
BenchmarkArrayDiff/ArrayDiffInclude_10-4         5000000               303 ns/op

On 100 items it was changed:

BenchmarkArrayDiff/ArrayDiffMap_90-4              100000             11825 ns/op
BenchmarkArrayDiff/ArrayDiffInclude_90-4          100000             12056 ns/op

On 1000 items:

BenchmarkArrayDiff/ArrayDiffMap_990-4            10000            124874 ns/op
BenchmarkArrayDiff/ArrayDiffInclude_990-4         2000            953394 ns/op

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArrayDiffInclude

func ArrayDiffInclude(a, b []int) []int

func ArrayDiffMap

func ArrayDiffMap(a, b []int) []int

Types

This section is empty.

Jump to

Keyboard shortcuts

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