Skip to content

Commit

Permalink
add some benchmarking
Browse files Browse the repository at this point in the history
  • Loading branch information
absolutelightning committed Aug 18, 2024
1 parent b0d66ad commit 2aa7303
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1796,6 +1796,30 @@ func BenchmarkTestARTree_InsertAndSearchWords(b *testing.B) {
}
}

func BenchmarkTestARTree_InsertAndSearchWords1(b *testing.B) {

art := NewRadixTree[int]()

file, _ := os.Open("test-text/words.txt")
defer file.Close()

scanner := bufio.NewScanner(file)
var lines []string
for scanner.Scan() {
line := scanner.Text()
lines = append(lines, line)
}

for _, line := range lines {
art, _, _ = art.Insert([]byte(line), 0)
}

b.ResetTimer()
for i := 1; i < b.N; i++ {
_, _ = art.Get([]byte(lines[i%(len(lines))]))
}
}

func BenchmarkMixedOperations(b *testing.B) {
dataset := generateDataset(datasetSize)
art := NewRadixTree[int]()
Expand Down

0 comments on commit 2aa7303

Please sign in to comment.