summarize: Update benchmarks
Joseph Kato
7 years ago
5 | 5 | "testing" |
6 | 6 | |
7 | 7 | "github.com/jdkato/prose/internal/util" |
8 | "github.com/jdkato/syllables" | |
8 | 9 | "github.com/stretchr/testify/assert" |
9 | 10 | ) |
10 | 11 | |
15 | 16 | |
16 | 17 | for word, count := range tests { |
17 | 18 | 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 | } | |
18 | 43 | } |
19 | 44 | } |
20 | 45 |