case "replace":
if target != nil && len(args) >= 2 {
sz := l.sizeEstimate(*target)
toReplaceSz := l.sizeEstimate(args[0])
replaceWithSz := l.sizeEstimate(args[1])
fmt.Printf("replace sz: %v\n", sz)
fmt.Printf("toReplaceSz: %v\n", toReplaceSz)
fmt.Printf("replaceWithSz: %v\n", replaceWithSz)
// smallest possible result: smallest input size composed of the largest possible substrings being replaced
minSz := uint64(math.Ceil(float64(sz.Min)/float64(toReplaceSz.Max))) * replaceWithSz.Min
// largest possible result: largest input size composed of the smallest possible substrings being replaced b
maxSz := uint64(math.Ceil(float64(sz.Max)/float64(toReplaceSz.Min))) * replaceWithSz.Max
fmt.Printf("float64(sz.Max): %v, float64(toReplaceSz.Min): %v\n", float64(sz.Max), float64(toReplaceSz.Min))
fmt.Printf("math.Ceil: %v\n", math.Ceil(float64(sz.Max)/float64(toReplaceSz.Min)))
fmt.Printf("uint64: %v\n", uint64(math.Ceil(float64(sz.Max)/float64(toReplaceSz.Min))))
fmt.Printf("*: %v", uint64(math.Ceil(float64(sz.Max)/float64(toReplaceSz.Min))) * replaceWithSz.Max)
// cost is the traversal plus the construction of the result
fmt.Printf(" minSz: %v, maxSz: %v\n", minSz, maxSz)
return &checker.CallEstimate{CostEstimate: sz.MultiplyByCostFactor(2 * common.StringTraversalCostFactor), Re
}
ppc64le
EstimateCallCost: replace
replace sz: {0 3145726}
toReplaceSz: {0 3145726}
replaceWithSz: {0 3145726}
float64(sz.Max): 3.145726e+06, float64(toReplaceSz.Min): 0
math.Ceil: +Inf
uint64: 18446744073709551615
*: 18446744073706405890 minSz: 0, maxSz: 18446744073706405890
checking size string_replace_string_string, cost: {4 629150}, resultSize: &{0 18446744073706405890}
EstimateCallCost: _==_
compilation_test.go:1223: Wrong cost (expected 629152, got 629154)
=== RUN TestCostEstimation/extended_library_replace/set_maxLength
EstimateCallCost: replace
replace sz: {0 40}
toReplaceSz: {0 40}
replaceWithSz: {0 40}
float64(sz.Max): 40, float64(toReplaceSz.Min): 0
math.Ceil: +Inf
uint64: 18446744073709551615
*: 18446744073709551576 minSz: 0, maxSz: 18446744073709551576
checking size string_replace_string_string, cost: {4 12}, resultSize: &{0 18446744073709551576}
EstimateCallCost: _==_
compilation_test.go:1223: Wrong cost (expected 14, got 16)
--- FAIL: TestCostEstimation (0.18s)
--- FAIL: TestCostEstimation/extended_library_replace (0.17s)
--- FAIL: TestCostEstimation/extended_library_replace/calc_maxLength (0.15s)
--- FAIL: TestCostEstimation/extended_library_replace/set_maxLength (0.01s)
FAIL
FAIL k8s.io/apiextensions-apiserver/pkg/apiserver/schema/cel 0.767s
FAIL
amd64:
replace sz: {0 3145726}
toReplaceSz: {0 3145726}
replaceWithSz: {0 3145726}
float64(sz.Max): 3.145726e+06, float64(toReplaceSz.Min): 0
math.Ceil: +Inf
uint64: 9223372036854775808
*: 0 minSz: 0, maxSz: 0
checking size string_replace_string_string, cost: {4 629150}, resultSize: &{0 0}
=== RUN TestCostEstimation/extended_library_replace/set_maxLength
replace sz: {0 40}
toReplaceSz: {0 40}
replaceWithSz: {0 40}
float64(sz.Max): 40, float64(toReplaceSz.Min): 0
math.Ceil: +Inf
uint64: 9223372036854775808
*: 0 minSz: 0, maxSz: 0
checking size string_replace_string_string, cost: {4 12}, resultSize: &{0 0}
--- PASS: TestCostEstimation (0.01s)
--- PASS: TestCostEstimation/extended_library_replace (0.01s)
--- PASS: TestCostEstimation/extended_library_replace/calc_maxLength (0.00s)
--- PASS: TestCostEstimation/extended_library_replace/set_maxLength (0.00s)
PASS
ok k8s.io/apiextensions-apiserver/pkg/apiserver/schema/cel 0.113s