Codebase list golang-github-jdkato-prose / 9c93797
summarize: Update benchmarks Joseph Kato 7 years ago
1 changed file(s) with 25 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
55 "testing"
66
77 "github.com/jdkato/prose/internal/util"
8 "github.com/jdkato/syllables"
89 "github.com/stretchr/testify/assert"
910 )
1011
1516
1617 for word, count := range tests {
1718 assert.Equal(t, count, Syllables(word), word)
19 }
20 }
21
22 func BenchmarkSyllables(b *testing.B) {
23 cases := util.ReadDataFile(filepath.Join(testdata, "syllables.json"))
24 tests := make(map[string]int)
25 util.CheckError(json.Unmarshal(cases, &tests))
26
27 for n := 0; n < b.N; n++ {
28 for word := range tests {
29 Syllables(word)
30 }
31 }
32 }
33
34 func BenchmarkSyllablesIn(b *testing.B) {
35 cases := util.ReadDataFile(filepath.Join(testdata, "syllables.json"))
36 tests := make(map[string]int)
37 util.CheckError(json.Unmarshal(cases, &tests))
38
39 for n := 0; n < b.N; n++ {
40 for word := range tests {
41 syllables.In(word)
42 }
1843 }
1944 }
2045