aboutsummaryrefslogtreecommitdiff
path: root/formatter_bench_test.go
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-01-31 02:35:58 +0000
committerFuwn <[email protected]>2026-01-31 02:35:58 +0000
commit3b4177fde5d0884e10c920de7f061474f6b69378 (patch)
treee36b4977a1179859d82503b06b93dd6e63df9ebf /formatter_bench_test.go
downloadiku-3b4177fde5d0884e10c920de7f061474f6b69378.tar.xz
iku-3b4177fde5d0884e10c920de7f061474f6b69378.zip
feat: Initial commit
Diffstat (limited to 'formatter_bench_test.go')
-rw-r--r--formatter_bench_test.go49
1 files changed, 49 insertions, 0 deletions
diff --git a/formatter_bench_test.go b/formatter_bench_test.go
new file mode 100644
index 0000000..53f607b
--- /dev/null
+++ b/formatter_bench_test.go
@@ -0,0 +1,49 @@
+package main
+
+import (
+ "strings"
+ "testing"
+)
+
+func BenchmarkFormat_Small(b *testing.B) {
+ input := []byte(`package main
+func main() {
+ x := 1
+ y := 2
+ if x > 0 {
+ z := 3
+ }
+ a := 4
+}
+`)
+ f := &Formatter{CommentMode: CommentsFollow}
+
+ for b.Loop() {
+ _, _ = f.Format(input)
+ }
+}
+
+func BenchmarkFormat_Large(b *testing.B) {
+ var sb strings.Builder
+
+ sb.WriteString("package main\n\n")
+
+ for i := range 100 {
+ sb.WriteString("func foo")
+ sb.WriteString(string(rune('A' + i%26)))
+ sb.WriteString("() {\n")
+ sb.WriteString("\tx := 1\n")
+ sb.WriteString("\tif x > 0 {\n")
+ sb.WriteString("\t\ty := 2\n")
+ sb.WriteString("\t}\n")
+ sb.WriteString("\tz := 3\n")
+ sb.WriteString("}\n\n")
+ }
+
+ input := []byte(sb.String())
+ f := &Formatter{CommentMode: CommentsFollow}
+
+ for b.Loop() {
+ _, _ = f.Format(input)
+ }
+}