-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: slimtrie: use quick creating impl; add slimtrie building be…
…nchmark
- Loading branch information
1 parent
39580b9
commit 089c8ea
Showing
2 changed files
with
30 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package trie_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/openacid/slim/encode" | ||
"github.com/openacid/slim/trie" | ||
) | ||
|
||
var Output int | ||
|
||
func BenchmarkNewSlimTrie(b *testing.B) { | ||
keys := words2 | ||
values := make([]uint32, len(keys)) | ||
for i := 0; i < len(keys); i++ { | ||
values[i] = uint32(i) | ||
} | ||
b.ResetTimer() | ||
var s int | ||
for i := 0; i < b.N; i++ { | ||
st, err := trie.NewSlimTrie(encode.U32{}, keys, values) | ||
if err != nil { | ||
panic(err) | ||
} | ||
s += int(st.Children.Cnt) | ||
} | ||
|
||
Output = s | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters