33 lines
1.3 KiB
Go
33 lines
1.3 KiB
Go
package membank
|
||
|
||
import (
|
||
"fmt"
|
||
"strings"
|
||
"testing"
|
||
|
||
"textmachine/backend/internal/lang"
|
||
"textmachine/backend/internal/store"
|
||
)
|
||
|
||
// BenchmarkScanShippingOnARealisticUnit sizes the book-consistency scan against the only number that
|
||
// matters for a 2283-chapter book: seconds per whole-book pass. research/34 flags this cost as never
|
||
// estimated by anyone.
|
||
func BenchmarkScanShippingOnARealisticUnit(b *testing.B) {
|
||
for _, rows := range []int{69, 200} {
|
||
var g []store.GlossaryEntry
|
||
for i := 0; i < rows; i++ {
|
||
e := gl(fmt.Sprintf("术%d语", i), fmt.Sprintf("термин-%d", i), "", "draft")
|
||
e.Decl = declJSON(false, fmt.Sprintf("термина-%d", i), fmt.Sprintf("термину-%d", i))
|
||
g = append(g, e)
|
||
}
|
||
bank := MaterializeBank(BankInput{Rows: g, TargetStemmer: lang.NewTargetStemmer(lang.TargetChecksFor("ru"))}, false)
|
||
// A unit's source is ~2.4k Han chars and its shipped text ~8k chars of Russian (run A, ch3).
|
||
src := strings.Repeat("术7语在这里。她走了。", 200)
|
||
out := strings.Repeat("термина-7 стоял у окна и молча ждал рассвета над рекой. ", 150)
|
||
b.Run(fmt.Sprintf("rows=%d", rows), func(b *testing.B) {
|
||
for i := 0; i < b.N; i++ {
|
||
bank.ScanShipping(src, out, 1)
|
||
}
|
||
})
|
||
}
|
||
}
|