Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
corscheid committed Feb 15, 2025
1 parent c8506e4 commit 4a259f2
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions fwew_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (

func TestMain(m *testing.M) {
// assure dict, so tests wont fail
AssureDict()
_ = AssureDict()

// call flag.Parse() here if TestMain uses flags
if testing.CoverMode() != "" {
Expand Down Expand Up @@ -1164,14 +1164,14 @@ func BenchmarkTranslateFromNavi(b *testing.B) {
for _, bm := range naviWords {
b.Run(bm.name, func(b *testing.B) {
for i := 0; i < b.N; i++ {
TranslateFromNaviHash(bm.args.searchNaviText, true, false)
_, _ = TranslateFromNaviHash(bm.args.searchNaviText, true, false)
}
})
}
}

func BenchmarkTranslateFromNaviCached(b *testing.B) {
CacheDictHash()
_ = CacheDictHash()
BenchmarkTranslateFromNavi(b)
UncacheHashDict()
}
Expand All @@ -1181,22 +1181,27 @@ func BenchmarkTranslateFromNaviBig(b *testing.B) {
if err != nil {
return
}
defer open.Close()
defer func(open *os.File) {
err := open.Close()
if err != nil {
panic(err)
}
}(open)

scanner := bufio.NewScanner(open)
for scanner.Scan() {
line := scanner.Text()

b.Run(line, func(b *testing.B) {
for i := 0; i < b.N; i++ {
TranslateFromNaviHash(line, true, false)
_, _ = TranslateFromNaviHash(line, true, false)
}
})
}
}

func BenchmarkTranslateFromNaviBigCached(b *testing.B) {
CacheDictHash()
_ = CacheDictHash()
BenchmarkTranslateFromNaviBig(b)
UncacheHashDict()
}
Expand Down Expand Up @@ -1295,7 +1300,12 @@ func BenchmarkTranslateToNaviBig(b *testing.B) {
if err != nil {
return
}
defer open.Close()
defer func(open *os.File) {
err := open.Close()
if err != nil {
panic(err)
}
}(open)

scanner := bufio.NewScanner(open)
for scanner.Scan() {
Expand All @@ -1310,7 +1320,7 @@ func BenchmarkTranslateToNaviBig(b *testing.B) {
}

func BenchmarkTranslateToNaviBigCached(b *testing.B) {
CacheDictHash2()
_ = CacheDictHash2()
BenchmarkTranslateToNaviBig(b)
UncacheHashDict2()
}
Expand Down Expand Up @@ -1376,7 +1386,7 @@ func TestRandom(t *testing.T) {
}

func TestRandomCached(t *testing.T) {
CacheDictHash()
_ = CacheDictHash()
TestRandom(t)
UncacheHashDict()
}

0 comments on commit 4a259f2

Please sign in to comment.