(provider string, cost modelsDevCost)
| 843 | } |
| 844 | |
| 845 | func buildModelsDevCandidate(provider string, cost modelsDevCost) (modelsDevCandidate, bool) { |
| 846 | if cost.Input == nil { |
| 847 | return modelsDevCandidate{}, false |
| 848 | } |
| 849 | |
| 850 | input := *cost.Input |
| 851 | if !isValidNonNegativeCost(input) { |
| 852 | return modelsDevCandidate{}, false |
| 853 | } |
| 854 | |
| 855 | var output *float64 |
| 856 | if cost.Output != nil { |
| 857 | if !isValidNonNegativeCost(*cost.Output) { |
| 858 | return modelsDevCandidate{}, false |
| 859 | } |
| 860 | output = cloneFloatPtr(cost.Output) |
| 861 | } |
| 862 | |
| 863 | // input=0/output>0 cannot be transformed into local ratio. |
| 864 | if input == 0 && output != nil && *output > 0 { |
| 865 | return modelsDevCandidate{}, false |
| 866 | } |
| 867 | |
| 868 | var cacheRead *float64 |
| 869 | if cost.CacheRead != nil && isValidNonNegativeCost(*cost.CacheRead) { |
| 870 | cacheRead = cloneFloatPtr(cost.CacheRead) |
| 871 | } |
| 872 | |
| 873 | return modelsDevCandidate{ |
| 874 | Provider: provider, |
| 875 | Input: input, |
| 876 | Output: output, |
| 877 | CacheRead: cacheRead, |
| 878 | }, true |
| 879 | } |
| 880 | |
| 881 | func shouldReplaceModelsDevCandidate(current, next modelsDevCandidate) bool { |
| 882 | currentNonZero := current.Input > 0 |
no test coverage detected