MCPcopy Create free account
hub / github.com/astercloud/aster / BenchmarkTool

Function BenchmarkTool

pkg/tools/builtin/testutils.go:462–476  ·  view source on GitHub ↗

BenchmarkTool 工具性能基准测试辅助函数

(b *testing.B, tool tools.Tool, input map[string]any)

Source from the content-addressed store, hash-verified

460
461// BenchmarkTool 工具性能基准测试辅助函数
462func BenchmarkTool(b *testing.B, tool tools.Tool, input map[string]any) {
463 ctx := context.Background()
464 tc := &tools.ToolContext{
465 Signal: ctx,
466 Sandbox: sandbox.NewMockSandbox(),
467 }
468
469 b.ResetTimer()
470 for range b.N {
471 _, err := tool.Execute(ctx, input, tc)
472 if err != nil {
473 b.Fatalf("Tool execution failed: %v", err)
474 }
475 }
476}

Calls 2

NewMockSandboxFunction · 0.92
ExecuteMethod · 0.65