summaryrefslogtreecommitdiff
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.go40
1 files changed, 39 insertions, 1 deletions
diff --git a/libgo/go/html/escape_test.go b/libgo/go/html/escape_test.go
index 2d7ad8ac266..3702626a3dc 100644
--- a/libgo/go/html/escape_test.go
+++ b/libgo/go/html/escape_test.go
@@ -4,7 +4,10 @@
package html
-import "testing"
+import (
+ "strings"
+ "testing"
+)
type unescapeTest struct {
// A short description of the test case.
@@ -113,3 +116,38 @@ 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)
+)
+
+func BenchmarkEscape(b *testing.B) {
+ n := 0
+ for i := 0; i < b.N; i++ {
+ n += len(EscapeString(benchEscapeData))
+ }
+}
+
+func BenchmarkEscapeNone(b *testing.B) {
+ n := 0
+ for i := 0; i < b.N; i++ {
+ n += len(EscapeString(benchEscapeNone))
+ }
+}
+
+func BenchmarkUnescape(b *testing.B) {
+ s := EscapeString(benchEscapeData)
+ n := 0
+ for i := 0; i < b.N; i++ {
+ n += len(UnescapeString(s))
+ }
+}
+
+func BenchmarkUnescapeNone(b *testing.B) {
+ s := EscapeString(benchEscapeNone)
+ n := 0
+ for i := 0; i < b.N; i++ {
+ n += len(UnescapeString(s))
+ }
+}