Switch from Asuka to MyGo, keeping the API client and the feature set: - servers: saved servers, passwordless and password login, proxy, self-signed certificates, per-server device tokens (Keystore), connect form, instance list sheet with switch/disconnect - sessions: virtualized list, search, new session, rename/archive/delete, running indicator, event stream keeps it live - chat: pushed window with system back bar, streaming Markdown via ui/markdown, reasoning and tool rows with image previews, footer menu (read aloud via a Kotlin TTS plugin, copy, fork), user message menu (copy, revert, fork), context usage ring and detail sheet, attachments (photos/files via the document picker), permissions - release builds allow plain http:// LAN servers (Go's net/http dials directly, no cleartext manifest needed) - a local fork of MyGo (third_party/mygo) lowers the Android host's minSdk to 24 (Android 7.0); Go 1.27.4 via mise Version 0.3.0.
57 lines
1.3 KiB
Go
57 lines
1.3 KiB
Go
package editor
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// largeText is a document of n lines of code, about 30 bytes each.
|
|
func largeText(n int) string {
|
|
var s strings.Builder
|
|
for i := range n {
|
|
fmt.Fprintf(&s, "func f%d() int { return %d }\n", i, i)
|
|
}
|
|
return s.String()
|
|
}
|
|
|
|
// Typing into a large document, each character a step of undo.
|
|
func BenchmarkBufferEditLarge(b *testing.B) {
|
|
buf := NewBuffer(largeText(100_000))
|
|
at := buf.Len() / 2
|
|
for b.Loop() {
|
|
buf.Edit(Edit{Start: at, End: at, Text: "x"})
|
|
at++
|
|
}
|
|
}
|
|
|
|
// Undoing and redoing a step of a large document with a long history.
|
|
func BenchmarkBufferUndoLarge(b *testing.B) {
|
|
buf := NewBuffer(largeText(100_000))
|
|
for i := range 1000 {
|
|
at := buf.Offset(Pos{Line: i * 100, Col: 5})
|
|
buf.Edit(Edit{Start: at, End: at + 2, Text: "abc"})
|
|
}
|
|
for b.Loop() {
|
|
buf.Undo()
|
|
buf.Redo()
|
|
}
|
|
}
|
|
|
|
// Modified of a large document, undone back to its saved text and with
|
|
// a text of another length.
|
|
func BenchmarkBufferModifiedLarge(b *testing.B) {
|
|
for _, undone := range []bool{true, false} {
|
|
b.Run(fmt.Sprintf("undone=%v", undone), func(b *testing.B) {
|
|
buf := NewBuffer(largeText(100_000))
|
|
buf.Edit(Edit{Start: 10, End: 10, Text: "x"})
|
|
if undone {
|
|
buf.Undo()
|
|
}
|
|
for b.Loop() {
|
|
buf.Modified()
|
|
}
|
|
})
|
|
}
|
|
}
|