Files
openchamber-android-native/third_party/mygo/internal/gpu/gl/bench_test.go
T
OpenChamber 6c0ee61750 feat: port the client to MyGo native UI (0.3.0)
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.
2026-11-18 13:22:59 +08:00

87 lines
2.5 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//go:build linux && !android && (amd64 || arm64)
package gl
import (
"runtime"
"testing"
"github.com/egoist/mygo/internal/gpu/gputest"
"github.com/egoist/mygo/internal/scene"
)
// BenchmarkRenderSprites draws frames of a 2D game at 1280×720 (gputest's
// SpriteScene, tiles 2 times as large: about 1,800 sprites of one sheet)
// and reads each back, which waits for it. Where no GPU runs it, Mesa's
// llvmpipe draws on the CPU, so the time is mostly its own.
func BenchmarkRenderSprites(b *testing.B) {
benchRender(b, gputest.SpriteScene(1280, 720, 2, 3, 300))
}
// BenchmarkRenderEmpty draws frames of nothing at 1280×720: what the
// sprites' frames spend besides them.
func BenchmarkRenderEmpty(b *testing.B) {
benchRender(b, &scene.Scene{Width: 1280, Height: 720, Clear: scene.Color{A: 255}})
}
func benchRender(b *testing.B, s *scene.Scene) {
runtime.LockOSThread()
defer runtime.UnlockOSThread()
o, err := NewOffscreen(false, s.Width, s.Height)
if err != nil {
b.Skip(err)
}
defer o.Release()
for b.Loop() {
if _, err := o.Render(s); err != nil {
b.Fatal(err)
}
}
}
// BenchmarkVideoFrameRGBA draws a new 1920×1080 frame of video each
// frame the way video drew before frames had surfaces: converted to RGBA
// on the CPU (as a decoder in Go would, or the CPU renderer does) and
// uploaded, 8 MB a frame.
func BenchmarkVideoFrameRGBA(b *testing.B) {
img := gputest.NV12Frame(1920, 1080, scene.BT709)
rgb := scene.NewImageRGBA(1920, 1080, nil)
s := videoBenchScene(rgb)
benchVideo(b, s, func() {
rgb.Pix = img.Surface.RGBA(rgb.Pix, 1920, 1080)
rgb.Changed()
})
}
// BenchmarkVideoFrameNV12 draws a new 1920×1080 frame of video each frame
// from its NV12 planes, as GStreamer leaves them: 3 MB uploaded, and
// converted in the shader.
func BenchmarkVideoFrameNV12(b *testing.B) {
img := gputest.NV12Frame(1920, 1080, scene.BT709)
s := videoBenchScene(img)
benchVideo(b, s, img.Changed)
}
func videoBenchScene(img *scene.Image) *scene.Scene {
return &scene.Scene{Width: 1280, Height: 720, Clear: scene.Color{A: 255}, Ops: []scene.Op{{
Kind: scene.OpImage, Rect: scene.Rect{W: 1280, H: 720}, Image: img, Src: scene.Rect{W: 1920, H: 1080},
}}}
}
func benchVideo(b *testing.B, s *scene.Scene, next func()) {
runtime.LockOSThread()
defer runtime.UnlockOSThread()
o, err := NewOffscreen(false, s.Width, s.Height)
if err != nil {
b.Skip(err)
}
defer o.Release()
b.SetBytes(1920 * 1080 * 4)
for b.Loop() {
next()
if _, err := o.Render(s); err != nil {
b.Fatal(err)
}
}
}