aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/html/escape_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/html/escape_test.go')
-rw-r--r--libgo/go/html/escape_test.go20
1 files changed, 18 insertions, 2 deletions
diff --git a/libgo/go/html/escape_test.go b/libgo/go/html/escape_test.go
index 3702626a3dc..8b51a55409f 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)+"&amp;", 10)
+ benchUnescapeDense = strings.Repeat("&amp;&lt; &amp; &lt;", 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))
+ }
+}