cmapv2
installation
In your Go project main directory (where the go.mod file is located)
go get github.com/sirgallo/cmapv2 go mod tidy
Make sure to run go mod tidy to install dependencies.
usage
package main import ( "github.com/sirgallo/cmapv2" ) func main() { // initialize c map cMap := cmap.NewMap() // insert key/val pair cMap.Put([]byte("hi"), []byte("world")) // retrieve value for key val := cMap.Get([]byte("hi")) // delete key/val pair cMap.Delete([]byte("hi")) // ===== OR // initialize sharded c map with number of shards sMap := cmap.NewMap(16) sMap.Put([]byte("hi"), []byte("world")) val := sMap.Get([]byte("hi")) sMap.Delete([]byte("hi")) }
tests
or with race:
or bench:
go test -v -bench=. -benchmem -cpuprofile cpu.prof -memprofile mem.prof -coverprofile=coverage.out ./
go tool cover -html=coverage.out -o cov.html
open cov.htmland check results:
go tool pprof -http=:8080 cmapv2.test cpu.prof go tool pprof -http=:8080 cmapv2.test mem.prof
benchmark
go test -v -bench=. -benchmem -cpuprofile cpu.prof -memprofile mem.prof ./benchmarksor with race:
go test -race -v -bench=. -benchmem -cpuprofile cpu.prof -memprofile mem.prof ./benchmarksfuzz
go test -fuzz=FuzzConcurrentOps -fuzztime=30s ./fuzz