mirror of
https://github.com/jeremyd/ergo.git
synced 2026-07-21 23:08:11 -07:00
tweaks to NAMES implementation (#2058)
* tweaks to NAMES implementation * tweak member caching * add a benchmark for NAMES
This commit is contained in:
committed by
GitHub
parent
378d88fee2
commit
eeec481b8d
@@ -43,3 +43,26 @@ func TestBuildTokenLines(t *testing.T) {
|
||||
val = BuildTokenLines(10, []string{"abcd", "efgh", "ijkl"}, ",")
|
||||
assertEqual(val, []string{"abcd,efgh", "ijkl"}, t)
|
||||
}
|
||||
|
||||
func TestTLBuilderAddParts(t *testing.T) {
|
||||
var tl TokenLineBuilder
|
||||
tl.Initialize(20, " ")
|
||||
tl.Add("bob")
|
||||
tl.AddParts("@", "alice")
|
||||
tl.AddParts("@", "ErgoBot__")
|
||||
assertEqual(tl.Lines(), []string{"bob @alice", "@ErgoBot__"}, t)
|
||||
}
|
||||
|
||||
func BenchmarkTokenLines(b *testing.B) {
|
||||
tokens := strings.Fields(monteCristo)
|
||||
b.ResetTimer()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
var tl TokenLineBuilder
|
||||
tl.Initialize(400, " ")
|
||||
for _, tok := range tokens {
|
||||
tl.Add(tok)
|
||||
}
|
||||
tl.Lines()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user