diff --git a/parse_test.go b/parse_test.go index 0201c57..365a5ab 100644 --- a/parse_test.go +++ b/parse_test.go @@ -147,16 +147,32 @@ func TestParseString (test *testing.T) { func BenchmarkParseStringLatin (benchmark *testing.B) { benchmark.ReportAllocs() + var meanLen, meanCap int for i := 0; i < benchmark.N; i ++ { - parseString(lipsumLt) + runes, _ := parseString(lipsumLt) + meanLen += len(runes) + meanCap += cap(runes) } + meanLen /= benchmark.N + meanCap /= benchmark.N + benchmark.ReportMetric(float64(meanLen), "len") + benchmark.ReportMetric(float64(meanCap), "cap") + benchmark.ReportMetric(float64(meanCap - meanLen), "waste") } func BenchmarkParseStringChinese (benchmark *testing.B) { benchmark.ReportAllocs() + var meanLen, meanCap int for i := 0; i < benchmark.N; i ++ { - parseString(lipsumCn) + runes, _ := parseString(lipsumCn) + meanLen += len(runes) + meanCap += cap(runes) } + meanLen /= benchmark.N + meanCap /= benchmark.N + benchmark.ReportMetric(float64(meanLen), "len") + benchmark.ReportMetric(float64(meanCap), "cap") + benchmark.ReportMetric(float64(meanCap - meanLen), "waste") } const lipsumLt =