Giter VIP home page Giter VIP logo

gensort's Introduction

Features

  • Sorting of numeric type slices;
  • Quick, bubble and insertion sorting;
  • Native generics support;
  • Covered by fuzzing and benchmarks;

Gensort

Usage

Code example

package main

import (
	"fmt"
	"github.com/vrumg/gensort"
)

func main() {
	slice := []int{5, 9, 0, 4, 2, 8, 3, 7, 6, 1}
	gensort.QuickSort(slice)
	fmt.Println(slice)
}

Output

go run main.go

[0 1 2 3 4 5 6 7 8 9]

Benchmarks

Comparison of bubble, insertion, quick and native go sorting algorithms on 10.000 elements slices.
OS: Linux
Arch: amd64
CPU: AMD Ryzen 7 3700X 8-Core Processor\

go test -bench=. -benchmem

goos: linux
goarch: amd64
pkg: github.com/vrumg/gensort
cpu: AMD Ryzen 7 3700X 8-Core Processor
BenchmarkBubbleSort-16                16          68920794 ns/op          161920 B/op      10001 allocs/op
BenchmarkInsertionSort-16             27          42216993 ns/op          161920 B/op      10001 allocs/op
BenchmarkQuickSort-16               1508            778599 ns/op          161921 B/op      10001 allocs/op
BenchmarkNativeSort-16              1005           1188826 ns/op          161977 B/op      10003 allocs/op

gensort's People

Watchers

Vlad Ulianov avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.