Implementation of basic algorithms and data structures with Go programming language. Tests and benchmarks are included
- Bubble sort (benchmarks) (wiki)
- Insertion sort (benchmarks) (wiki)
- Shellsort (benchmarks) (wiki)
- Selection sort (benchmarks) (wiki)
- Merge sort (benchmarks) (wiki)
- Quicksort (benchmarks) (wiki)
- Counting sort (benchmarks) (wiki)
- Radix sort (benchmarks) (wiki)
- Heapsort (benchmarks) (wiki)
- Linear search (benchmarks) (wiki)
- Interpolation search (benchmarks) (wiki)
- Binary search (benchmarks) (wiki)
To start benchmarks is needed to use the standard utility go test
. It allows to execute the following commands:
go test -run=- -bench=. -benchmem
go test -run=- -bench=. -benchmem > benchmarks.txt
Script bench.sh
allows to run tests without visiting the directory with the package:
./bench.sh $1 $2
where $1
is the name of the package, for example sort/bubblesort
, And $2
an optional value - if it's not
specified, the result is written to file benchmarks.txt
. If parameter is set, result of execution is output
to the console. For example:
./bench.sh sort/heapsort false
./bench.sh sort/heapsort
is equivalent to the following commands:
go test github.com/ganelon13/go-algorithms/sort/heapsort -run=- -bench=. -benchmem
go test github.com/ganelon13/go-algorithms/sort/heapsort -run=- -bench=. -benchmem > sort/heapsort/benchmarks.txt
Under the control of the Windows operating system script bench.sh
can be executed provided that the system has a
unix terminal emulator installed, for example cygwin. Then the following command format is
available from cmd:
echo ./bench.sh sort/bubblesort false | bash
https://youtu.be/eqWzZGNO_XM?list=PLrCZzMib1e9pDxHYzmEzMmnMMUK-dz0_7
https://rosettacode.org/wiki/Sorting_algorithms