Skip to content

Commit

Permalink
bump go version to 1.22
Browse files Browse the repository at this point in the history
- go version 1.23 is released
- use range-over-int where possible
  • Loading branch information
gaissmai committed Aug 17, 2024
1 parent ce97f64 commit f3a587c
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 69 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
test:
strategy:
matrix:
go-version: ['1.21']
go-version: ['1.22']
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -27,7 +27,7 @@ jobs:
steps:
- uses: golang/govulncheck-action@v1
with:
go-version-input: 1.21
go-version-input: 1.22
check-latest: true

coverage:
Expand All @@ -36,7 +36,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.21
go-version: 1.22

- name: Test Coverage
run: go test -v -coverprofile=profile.cov ./...
Expand All @@ -51,7 +51,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.21
go-version: 1.22

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
Expand Down
44 changes: 22 additions & 22 deletions fulltable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func BenchmarkFullTableInsert(b *testing.B) {
var rt Table[struct{}]

b.ResetTimer()
for k := 0; k < b.N; k++ {
for range b.N {
for _, route := range routes6 {
rt.Insert(route.CIDR, struct{}{})
}
Expand Down Expand Up @@ -82,21 +82,21 @@ func BenchmarkFullMatchV4(b *testing.B) {

b.Run("Lookup", func(b *testing.B) {
b.ResetTimer()
for k := 0; k < b.N; k++ {
for range b.N {
intSink, okSink = rt.Lookup(ip)
}
})

b.Run("LookupPrefix", func(b *testing.B) {
b.ResetTimer()
for k := 0; k < b.N; k++ {
for range b.N {
intSink, okSink = rt.LookupPrefix(ipAsPfx)
}
})

b.Run("LookupPrefixLPM", func(b *testing.B) {
b.ResetTimer()
for k := 0; k < b.N; k++ {
for range b.N {
_, intSink, okSink = rt.LookupPrefixLPM(ipAsPfx)
}
})
Expand Down Expand Up @@ -124,21 +124,21 @@ func BenchmarkFullMatchV6(b *testing.B) {

b.Run("Lookup", func(b *testing.B) {
b.ResetTimer()
for k := 0; k < b.N; k++ {
for range b.N {
intSink, okSink = rt.Lookup(ip)
}
})

b.Run("LookupPrefix", func(b *testing.B) {
b.ResetTimer()
for k := 0; k < b.N; k++ {
for range b.N {
intSink, okSink = rt.LookupPrefix(ipAsPfx)
}
})

b.Run("LookupPrefixLPM", func(b *testing.B) {
b.ResetTimer()
for k := 0; k < b.N; k++ {
for range b.N {
_, intSink, okSink = rt.LookupPrefixLPM(ipAsPfx)
}
})
Expand Down Expand Up @@ -166,21 +166,21 @@ func BenchmarkFullMissV4(b *testing.B) {

b.Run("Lookup", func(b *testing.B) {
b.ResetTimer()
for k := 0; k < b.N; k++ {
for range b.N {
intSink, okSink = rt.Lookup(ip)
}
})

b.Run("LookupPrefix", func(b *testing.B) {
b.ResetTimer()
for k := 0; k < b.N; k++ {
for range b.N {
intSink, okSink = rt.LookupPrefix(ipAsPfx)
}
})

b.Run("LookupPrefixLPM", func(b *testing.B) {
b.ResetTimer()
for k := 0; k < b.N; k++ {
for range b.N {
_, intSink, okSink = rt.LookupPrefixLPM(ipAsPfx)
}
})
Expand Down Expand Up @@ -208,21 +208,21 @@ func BenchmarkFullMissV6(b *testing.B) {

b.Run("Lookup", func(b *testing.B) {
b.ResetTimer()
for k := 0; k < b.N; k++ {
for range b.N {
intSink, okSink = rt.Lookup(ip)
}
})

b.Run("LookupPrefix", func(b *testing.B) {
b.ResetTimer()
for k := 0; k < b.N; k++ {
for range b.N {
intSink, okSink = rt.LookupPrefix(ipAsPfx)
}
})

b.Run("LookupPrefixLPM", func(b *testing.B) {
b.ResetTimer()
for k := 0; k < b.N; k++ {
for range b.N {
_, intSink, okSink = rt.LookupPrefixLPM(ipAsPfx)
}
})
Expand All @@ -244,7 +244,7 @@ func BenchmarkFullTableOverlapsV4(b *testing.B) {

b.Run(fmt.Sprintf("With_%4d", i), func(b *testing.B) {
b.ResetTimer()
for k := 0; k < b.N; k++ {
for range b.N {
boolSink = rt.Overlaps(inter)
}
})
Expand All @@ -267,7 +267,7 @@ func BenchmarkFullTableOverlapsV6(b *testing.B) {

b.Run(fmt.Sprintf("With_%4d", i), func(b *testing.B) {
b.ResetTimer()
for k := 0; k < b.N; k++ {
for range b.N {
boolSink = rt.Overlaps(inter)
}
})
Expand All @@ -290,7 +290,7 @@ func BenchmarkFullTableOverlaps(b *testing.B) {

b.Run(fmt.Sprintf("With_%4d", i), func(b *testing.B) {
b.ResetTimer()
for k := 0; k < b.N; k++ {
for range b.N {
boolSink = rt.Overlaps(inter)
}
})
Expand All @@ -305,7 +305,7 @@ func BenchmarkFullTableCloneV4(b *testing.B) {
}

b.ResetTimer()
for k := 0; k < b.N; k++ {
for range b.N {
cloneSink = rt.Clone()
}
}
Expand All @@ -318,7 +318,7 @@ func BenchmarkFullTableCloneV6(b *testing.B) {
}

b.ResetTimer()
for k := 0; k < b.N; k++ {
for range b.N {
cloneSink = rt.Clone()
}
}
Expand All @@ -331,7 +331,7 @@ func BenchmarkFullTableClone(b *testing.B) {
}

b.ResetTimer()
for k := 0; k < b.N; k++ {
for range b.N {
cloneSink = rt.Clone()
}
}
Expand All @@ -344,7 +344,7 @@ func BenchmarkFullTableMemoryV4(b *testing.B) {
runtime.ReadMemStats(&startMem)

b.Run(strconv.Itoa(len(routes4)), func(b *testing.B) {
for i := 0; i < b.N; i++ {
for range b.N {
for _, route := range routes4 {
rt.Insert(route.CIDR, struct{}{})
}
Expand All @@ -367,7 +367,7 @@ func BenchmarkFullTableMemoryV6(b *testing.B) {
runtime.ReadMemStats(&startMem)

b.Run(strconv.Itoa(len(routes6)), func(b *testing.B) {
for i := 0; i < b.N; i++ {
for range b.N {
for _, route := range routes6 {
rt.Insert(route.CIDR, struct{}{})
}
Expand All @@ -390,7 +390,7 @@ func BenchmarkFullTableMemory(b *testing.B) {
runtime.ReadMemStats(&startMem)

b.Run(strconv.Itoa(len(routes)), func(b *testing.B) {
for i := 0; i < b.N; i++ {
for range b.N {
for _, route := range routes {
rt.Insert(route.CIDR, struct{}{})
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module github.com/gaissmai/bart

go 1.21.0
go 1.22.0

require github.com/bits-and-blooms/bitset v1.13.0
36 changes: 18 additions & 18 deletions node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

func TestInverseIndex(t *testing.T) {
t.Parallel()
for i := 0; i < maxNodeChildren; i++ {
for i := range maxNodeChildren {
for bits := 0; bits <= strideLen; bits++ {
octet := byte(i & (0xFF << (strideLen - bits)))
idx := prefixToBaseIndex(byte(octet), bits)
Expand Down Expand Up @@ -180,7 +180,7 @@ func BenchmarkNodePrefixInsert(b *testing.B) {
route := routes[rand.Intn(len(routes))]

b.ResetTimer()
for i := 0; i < b.N; i++ {
for range b.N {
node.insertPrefix(prefixToBaseIndex(route.octet, route.bits), 0)
}
})
Expand All @@ -204,7 +204,7 @@ func BenchmarkNodePrefixUpdate(b *testing.B) {
route := routes[rand.Intn(len(routes))]

b.ResetTimer()
for i := 0; i < b.N; i++ {
for range b.N {
node.updatePrefix(route.octet, route.bits, func(int, bool) int { return 1 })
}
})
Expand All @@ -228,7 +228,7 @@ func BenchmarkNodePrefixDelete(b *testing.B) {
route := routes[rand.Intn(len(routes))]

b.ResetTimer()
for i := 0; i < b.N; i++ {
for range b.N {
node.deletePrefix(route.octet, route.bits)
}
})
Expand All @@ -254,7 +254,7 @@ func BenchmarkNodePrefixLPM(b *testing.B) {
route := routes[rand.Intn(len(routes))]

b.ResetTimer()
for i := 0; i < b.N; i++ {
for range b.N {
_, writeSink, _ = node.lpm(prefixToBaseIndex(route.octet, route.bits))
}
})
Expand All @@ -279,7 +279,7 @@ func BenchmarkNodePrefixRank(b *testing.B) {
baseIdx := prefixToBaseIndex(route.octet, route.bits)

b.ResetTimer()
for i := 0; i < b.N; i++ {
for range b.N {
writeSink = node.prefixRank(baseIdx)
}
})
Expand All @@ -302,7 +302,7 @@ func BenchmarkNodePrefixNextSetMany(b *testing.B) {
b.Run(fmt.Sprintf("IN %d", nroutes), func(b *testing.B) {
idxBackingArray := [maxNodePrefixes]uint{}
b.ResetTimer()
for i := 0; i < b.N; i++ {
for range b.N {
node.allStrideIndexes(idxBackingArray[:])
}
})
Expand Down Expand Up @@ -333,7 +333,7 @@ func BenchmarkNodePrefixIntersectionCardinality(b *testing.B) {

b.Run(fmt.Sprintf("With %d", nroutes), func(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
for range b.N {
node.prefixesBitset.IntersectionCardinality(other.prefixesBitset)
}
})
Expand All @@ -344,7 +344,7 @@ func BenchmarkNodeChildInsert(b *testing.B) {
for _, nchilds := range childCount {
node := newNode[int]()

for i := 0; i < nchilds; i++ {
for range nchilds {
octet := rand.Intn(maxNodeChildren)
node.insertChild(byte(octet), nil)
}
Expand All @@ -353,7 +353,7 @@ func BenchmarkNodeChildInsert(b *testing.B) {
octet := rand.Intn(maxNodeChildren)

b.ResetTimer()
for i := 0; i < b.N; i++ {
for range b.N {
node.insertChild(byte(octet), nil)
}
})
Expand All @@ -364,7 +364,7 @@ func BenchmarkNodeChildDelete(b *testing.B) {
for _, nchilds := range childCount {
node := newNode[int]()

for i := 0; i < nchilds; i++ {
for range nchilds {
octet := rand.Intn(maxNodeChildren)
node.insertChild(byte(octet), nil)
}
Expand All @@ -373,7 +373,7 @@ func BenchmarkNodeChildDelete(b *testing.B) {
octet := rand.Intn(maxNodeChildren)

b.ResetTimer()
for i := 0; i < b.N; i++ {
for range b.N {
node.deleteChild(byte(octet))
}
})
Expand All @@ -384,7 +384,7 @@ func BenchmarkNodeChildRank(b *testing.B) {
for _, nchilds := range childCount {
node := newNode[int]()

for i := 0; i < nchilds; i++ {
for range nchilds {
octet := byte(rand.Intn(maxNodeChildren))
node.insertChild(octet, nil)
}
Expand All @@ -394,7 +394,7 @@ func BenchmarkNodeChildRank(b *testing.B) {
baseIdx := octetToBaseIndex(octet)

b.ResetTimer()
for i := 0; i < b.N; i++ {
for range b.N {
node.childRank(byte(baseIdx))
}
})
Expand All @@ -405,15 +405,15 @@ func BenchmarkNodeChildNextSetMany(b *testing.B) {
for _, nchilds := range childCount {
node := newNode[int]()

for i := 0; i < nchilds; i++ {
for range nchilds {
octet := byte(rand.Intn(maxNodeChildren))
node.insertChild(octet, nil)
}

b.Run(fmt.Sprintf("In %d", nchilds), func(b *testing.B) {
addrBackingArray := [maxNodeChildren]uint{}
b.ResetTimer()
for i := 0; i < b.N; i++ {
for range b.N {
node.allChildAddrs(addrBackingArray[:])
}
})
Expand All @@ -425,7 +425,7 @@ func BenchmarkNodeChildIntersectionCardinality(b *testing.B) {
node := newNode[int]()
other := newNode[int]()

for i := 0; i < nchilds; i++ {
for range nchilds {
octet := byte(rand.Intn(maxNodeChildren))
node.insertChild(octet, nil)

Expand All @@ -435,7 +435,7 @@ func BenchmarkNodeChildIntersectionCardinality(b *testing.B) {

b.Run(fmt.Sprintf("With %d", nchilds), func(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
for range b.N {
node.childrenBitset.IntersectionCardinality(other.childrenBitset)
}
})
Expand Down
Loading

0 comments on commit f3a587c

Please sign in to comment.