()
| 410 | } |
| 411 | |
| 412 | func extractCostTracker() interpreter.FunctionTracker { |
| 413 | return func(args []ref.Val, result ref.Val) *uint64 { |
| 414 | targetCost := float64(safeAdd(actualSize(args[0]), 1)) * common.StringTraversalCostFactor |
| 415 | regexCost := float64(safeAdd(actualSize(args[1]), 1)) * common.RegexStringLengthCostFactor |
| 416 | // Actual search cost calculation = targetCost + regexCost |
| 417 | searchCost := targetCost * regexCost |
| 418 | // The total cost is the base call cost + search cost + result string allocation. |
| 419 | totalCost := float64(callCost) + searchCost + float64(actualSize(result)) |
| 420 | // Round up and convert to uint64 for the final cost. |
| 421 | finalCost := uint64(math.Ceil(totalCost)) |
| 422 | return &finalCost |
| 423 | } |
| 424 | } |
| 425 | |
| 426 | func extractAllCostTracker() interpreter.FunctionTracker { |
| 427 | return func(args []ref.Val, result ref.Val) *uint64 { |
no test coverage detected