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>
26 lines
851 B
Go
26 lines
851 B
Go
// Copyright 2026 Alibaba Group
|
||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||
|
||
package builtin_test
|
||
|
||
import (
|
||
"testing"
|
||
|
||
"github.com/DingTalk-Real-AI/dingtalk-workspace-cli/internal/shortcut/builtin"
|
||
)
|
||
|
||
// BenchmarkShortcutCommands measures the Go-literal storage model: the 376
|
||
// shortcut definitions are compiled-in struct literals registered from init(),
|
||
// so there is no parse step at all — this times only turning them into the Cobra
|
||
// tree. ResolveMeta no longer pays full Catalog decode (~294–360ms / ~175MB);
|
||
// it reads assembled SchemaRegistry (BenchmarkResolveMetaFirstHit). Full Catalog
|
||
// assemble remains the dws schema / --all path.
|
||
func BenchmarkShortcutCommands(b *testing.B) {
|
||
b.ReportAllocs()
|
||
for i := 0; i < b.N; i++ {
|
||
if len(builtin.Commands()) == 0 {
|
||
b.Fatal("no shortcut commands")
|
||
}
|
||
}
|
||
}
|