Files
dingtalk-workspace-cli/internal/shortcut/builtin/loadcost_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

26 lines
851 B
Go
Raw Permalink 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.
// 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")
}
}
}