Skip to content

Commit

Permalink
move benchmarks to subdirectory
Browse files Browse the repository at this point in the history
  • Loading branch information
cornelk committed Aug 10, 2022
1 parent f969cad commit 32526d3
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ lint: ## run code linters
golangci-lint run

benchmark: ## run benchmarks
go test -cpu 8 -run=^# -bench=.
cd benchmarks && go test -cpu 8 -run=^# -bench=.

test: ## run tests
go test -race ./...
Expand Down
13 changes: 7 additions & 6 deletions benchmark_test.go → benchmarks/benchmark_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package hashmap
package benchmarks

import (
"strconv"
Expand All @@ -7,14 +7,15 @@ import (
"testing"

"github.com/alphadose/haxmap"
"github.com/cornelk/hashmap"
)

const benchmarkItemCount = 512

func setupHashMap(b *testing.B) *HashMap[uintptr, uintptr] {
func setupHashMap(b *testing.B) *hashmap.HashMap[uintptr, uintptr] {
b.Helper()

m := New[uintptr, uintptr]()
m := hashmap.New[uintptr, uintptr]()
for i := uintptr(0); i < benchmarkItemCount; i++ {
m.Set(i, i)
}
Expand All @@ -33,10 +34,10 @@ func setupHaxMap(b *testing.B) *haxmap.HashMap[uintptr, uintptr] {
return m
}

func setupHashMapString(b *testing.B) (*HashMap[string, string], []string) {
func setupHashMapString(b *testing.B) (*hashmap.HashMap[string, string], []string) {
b.Helper()

m := New[string, string]()
m := hashmap.New[string, string]()
keys := make([]string, benchmarkItemCount)
for i := 0; i < benchmarkItemCount; i++ {
s := strconv.Itoa(i)
Expand Down Expand Up @@ -331,7 +332,7 @@ func BenchmarkReadGoMapStringMutex(b *testing.B) {
}

func BenchmarkWriteHashMapUint(b *testing.B) {
m := New[uintptr, uintptr]()
m := hashmap.New[uintptr, uintptr]()

for n := 0; n < b.N; n++ {
for i := uintptr(0); i < benchmarkItemCount; i++ {
Expand Down
10 changes: 10 additions & 0 deletions benchmarks/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module github.com/cornelk/hashmap/benchmarks

go 1.19

require (
github.com/alphadose/haxmap v0.1.1-0.20220808155550-bc3b9a6adfc4
github.com/cornelk/hashmap v1.0.4-0.20220810053739-f969cadbb3f0
)

require github.com/cespare/xxhash v1.1.0 // indirect
14 changes: 14 additions & 0 deletions benchmarks/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/alphadose/haxmap v0.1.1-0.20220808155550-bc3b9a6adfc4 h1:E78W2LuJFjDKpr0a0xFK9w0rawO4wtmTdcbRX5H11mg=
github.com/alphadose/haxmap v0.1.1-0.20220808155550-bc3b9a6adfc4/go.mod h1:68nFwlFwh/HEilKSdlNOKnd1PwOy8EUnKUtZH2TdVb8=
github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/cornelk/hashmap v1.0.4-0.20220810053739-f969cadbb3f0 h1:jed6FFAMwRgg57mgmqH/kfSsjtXL8ocT3f2zE/8vumg=
github.com/cornelk/hashmap v1.0.4-0.20220810053739-f969cadbb3f0/go.mod h1:T9KPzj/SjvCwiF51NdfFMmqHhRm6cl2slzzgmmgDnUw=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72 h1:qLC7fQah7D6K1B0ujays3HV9gkFtllcxhzImRR7ArPQ=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module github.com/cornelk/hashmap
go 1.19

require (
github.com/alphadose/haxmap v0.1.1-0.20220808155550-bc3b9a6adfc4
github.com/cespare/xxhash v1.1.0
github.com/stretchr/testify v1.8.0
)
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/alphadose/haxmap v0.1.1-0.20220808155550-bc3b9a6adfc4 h1:E78W2LuJFjDKpr0a0xFK9w0rawO4wtmTdcbRX5H11mg=
github.com/alphadose/haxmap v0.1.1-0.20220808155550-bc3b9a6adfc4/go.mod h1:68nFwlFwh/HEilKSdlNOKnd1PwOy8EUnKUtZH2TdVb8=
github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down

0 comments on commit 32526d3

Please sign in to comment.