aboutsummaryrefslogtreecommitdiff
path: root/lib/html/benchmark_test.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2024-03-06 03:42:00 +0700
committerShulhan <ms@kilabit.info>2024-03-09 01:10:17 +0700
commite730418289d80985c5d48946353961a357a4b532 (patch)
tree9e573bf4fca975775eb25f32448f755a325880a8 /lib/html/benchmark_test.go
parent1e7cb99f42bcd41e98326bd9406d3cecfb2a4542 (diff)
downloadpakakeh.go-e730418289d80985c5d48946353961a357a4b532.tar.xz
lib: move package "net/html" to "lib/html"
Putting "html" under "net" package make no sense. Another reason is to make the package flat under "lib/" directory.
Diffstat (limited to 'lib/html/benchmark_test.go')
-rw-r--r--lib/html/benchmark_test.go45
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/html/benchmark_test.go b/lib/html/benchmark_test.go
new file mode 100644
index 00000000..05aa62d2
--- /dev/null
+++ b/lib/html/benchmark_test.go
@@ -0,0 +1,45 @@
+// Copyright 2022, Shulhan <ms@kilabit.info>. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package html
+
+import "testing"
+
+func BenchmarkNormalizeForID(b *testing.B) {
+ var (
+ cases = []string{
+ "",
+ ".123 ABC def",
+ }
+ x int
+ )
+ for ; x < b.N; x++ {
+ NormalizeForID(cases[0])
+ NormalizeForID(cases[1])
+ }
+}
+
+func BenchmarkSanitize(b *testing.B) {
+ var (
+ input = []byte(`
+<html>
+ <title>Test</title>
+ <head>
+ </head>
+ <body>
+ This
+ <p> is </p>
+ a
+ <a href="/">link</a>.
+ An another
+ <a href="/">link</a>.
+ </body>
+</html>`)
+ x int
+ )
+
+ for ; x < b.N; x++ {
+ Sanitize(input)
+ }
+}