Files
dingtalk-workspace-cli/internal/cli/schema_consumption_bench_test.go
玉澜andCursor 3d163242f5 fix(schema): cache ResolveMeta from runtime assembly Once
Keep declare→ResolveSchemaBuild as the ToolSpec authority, but materialize
map[cli_path]CommandMeta during deliverySchemaCatalog sync.Once so leaf
--help / ResolveMeta are O(1) after the first Schema touch. Defer wire
Catalog/Tools maps, stamp Source as runtime-assembled, drop committed
catalog/gob fixtures, and cover steady-state reuse with app/cli tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-02 10:07:19 +08:00

42 lines
951 B
Go

// Copyright 2026 Alibaba Group
// Licensed under the Apache License, Version 2.0 (the "License");
package cli
import "testing"
func BenchmarkDeliverySchemaCatalog(b *testing.B) {
if err := deliverySchemaCatalogError(); err != nil {
b.Fatalf("delivery catalog unavailable: %v", err)
}
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
resetDeliverySchemaCatalogStateForTest()
_ = deliverySchemaCatalog()
}
}
func BenchmarkResolveMetaSteadyState(b *testing.B) {
if _, ok := ResolveMeta("dev app delete"); !ok {
b.Fatal("ResolveMeta(dev app delete) missing")
}
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
_, _ = ResolveMeta("dev app delete")
}
}
func BenchmarkBuildMetaByCLIPath(b *testing.B) {
loaded := deliverySchemaCatalog()
if err := deliverySchemaCatalogError(); err != nil {
b.Fatal(err)
}
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
_ = buildMetaByCLIPath(loaded)
}
}