MCPcopy Create free account
hub / github.com/cel-expr/cel-go / extractAllCostTracker

Function extractAllCostTracker

ext/regex.go:426–438  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

424}
425
426func extractAllCostTracker() interpreter.FunctionTracker {
427 return func(args []ref.Val, result ref.Val) *uint64 {
428 targetCost := float64(actualSize(args[0])+1) * common.StringTraversalCostFactor
429 regexCost := float64(actualSize(args[1])+1) * common.RegexStringLengthCostFactor
430 // Actual search cost calculation = targetCost + regexCost
431 searchCost := targetCost * regexCost
432 // The total cost is the base call cost + search cost + result allocation + list creation cost factor.
433 totalCost := float64(callCost) + searchCost + float64(actualSize(result)) + common.ListCreateBaseCost
434 // Round up and convert to uint64 for the final cost.
435 finalCost := uint64(math.Ceil(totalCost))
436 return &finalCost
437 }
438}
439
440func replaceCostTracker() interpreter.FunctionTracker {
441 return func(args []ref.Val, result ref.Val) *uint64 {

Callers 1

ProgramOptionsMethod · 0.85

Calls 1

actualSizeFunction · 0.70

Tested by

no test coverage detected