diff options
Diffstat (limited to 'libgo/go/html/escape_test.go')
-rw-r--r-- | libgo/go/html/escape_test.go | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/libgo/go/html/escape_test.go b/libgo/go/html/escape_test.go index 3702626..8b51a55 100644 --- a/libgo/go/html/escape_test.go +++ b/libgo/go/html/escape_test.go @@ -118,8 +118,10 @@ func TestUnescapeEscape(t *testing.T) { } var ( - benchEscapeData = strings.Repeat("AAAAA < BBBBB > CCCCC & DDDDD ' EEEEE \" ", 100) - benchEscapeNone = strings.Repeat("AAAAA x BBBBB x CCCCC x DDDDD x EEEEE x ", 100) + benchEscapeData = strings.Repeat("AAAAA < BBBBB > CCCCC & DDDDD ' EEEEE \" ", 100) + benchEscapeNone = strings.Repeat("AAAAA x BBBBB x CCCCC x DDDDD x EEEEE x ", 100) + benchUnescapeSparse = strings.Repeat(strings.Repeat("AAAAA x BBBBB x CCCCC x DDDDD x EEEEE x ", 10)+"&", 10) + benchUnescapeDense = strings.Repeat("&< & <", 100) ) func BenchmarkEscape(b *testing.B) { @@ -151,3 +153,17 @@ func BenchmarkUnescapeNone(b *testing.B) { n += len(UnescapeString(s)) } } + +func BenchmarkUnescapeSparse(b *testing.B) { + n := 0 + for i := 0; i < b.N; i++ { + n += len(UnescapeString(benchUnescapeSparse)) + } +} + +func BenchmarkUnescapeDense(b *testing.B) { + n := 0 + for i := 0; i < b.N; i++ { + n += len(UnescapeString(benchUnescapeDense)) + } +} |