()
| 438 | } |
| 439 | |
| 440 | func replaceCostTracker() interpreter.FunctionTracker { |
| 441 | return func(args []ref.Val, result ref.Val) *uint64 { |
| 442 | targetCost := float64(actualSize(args[0])+1) * common.StringTraversalCostFactor |
| 443 | regexCost := float64(actualSize(args[1])+1) * common.RegexStringLengthCostFactor |
| 444 | // Actual search cost calculation = targetCost + regexCost |
| 445 | searchCost := targetCost * regexCost |
| 446 | // The total cost is the base call cost + search cost + result string allocation. |
| 447 | totalCost := float64(callCost) + searchCost + float64(actualSize(result)) |
| 448 | // Convert to uint64 for the final cost. |
| 449 | finalCost := uint64(totalCost) |
| 450 | return &finalCost |
| 451 | } |
| 452 | } |
no test coverage detected