Files
zerorigin-toolbox/cmd/toast-stress/main.go
T
zerorigin2019 0a1c1e82ea chore: 初始化仓库(零源工具箱 0.1.0 基线)
- Go 主进程 cmd/zerorigin(托盘常驻 + 触发器/规则/动作引擎)
- Wails v3 设置进程 cmd/settings(独立 module)
- 监督进程 cmd/watchdog(-supervise 异常重启)
- 构建脚本 build.bat / NSIS 安装包 deploy/、便携版 portable/
- 架构与 MVP 计划文档 docs/、阶段 0-4 验收记录 deploy/acceptance-0-4.md
2026-08-05 00:42:45 +08:00

39 lines
1.0 KiB
Go

package main
// toast-stress:压力测试验证修复后的通知 worker 线程模型。
// 高频连续调用 ShowBalloon(模拟滚轮连调音量触发 toast),
// 验证:1) 不崩溃 2) worker 线程稳定 3) NIM_MODIFY 复用正常。
import (
"fmt"
"os"
"time"
pwin "zerorigin/internal/platform/windows"
)
func main() {
count := 30
if len(os.Args) > 1 {
fmt.Sscanf(os.Args[1], "%d", &count)
}
fmt.Printf("=== toast-stress: 连续调用 ShowBalloon %d 次 ===\n", count)
start := time.Now()
var errs int
for i := 0; i < count; i++ {
title := "音量调节"
text := fmt.Sprintf("音量: %d%%", 40+i%30)
if err := pwin.ShowBalloon(title, text); err != nil {
errs++
fmt.Printf("[%02d] ShowBalloon ERROR: %v\n", i, err)
}
time.Sleep(80 * time.Millisecond)
}
elapsed := time.Since(start)
fmt.Printf("=== 完成: %d 次调用, %d 错误, 耗时 %v ===\n", count, errs, elapsed)
if errs == 0 {
fmt.Println("RESULT: PASS - worker 线程模型稳定,无崩溃")
} else {
fmt.Println("RESULT: FAIL - 有错误")
}
}