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

Function estimateListSortCost

ext/lists.go:818–826  ·  view source on GitHub ↗

estimateListSortCost estimates an O(n^2) sort operation with a cost factor of 2 for the equality operations which occur during the sort computation.

(estimator checker.CostEstimator, node checker.AstNode, elemType *types.Type)

Source from the content-addressed store, hash-verified

816// estimateListSortCost estimates an O(n^2) sort operation with a cost factor of 2 for the equality
817// operations which occur during the sort computation.
818func estimateListSortCost(estimator checker.CostEstimator, node checker.AstNode, elemType *types.Type) *checker.CallEstimate {
819 sz := estimateSize(estimator, node)
820 itemSize := estimateItemSize(estimator, node)
821 elemCost := estimateElementEqualityCost(estimator, elemType, itemSize)
822
823 costSize := sz.Multiply(sz)
824 cost := costSize.MultiplyByCost(elemCost).MultiplyByCostFactor(2.0)
825 return estimateListCallWithDirectCost(cost, sz, true)
826}
827
828// estimateAllocatingListCall computes cost as a function of the size of the result list with a
829// baseline cost for the call dispatch and the associated list allocation.

Callers 1

estimateListSortFunction · 0.85

Calls 7

estimateItemSizeFunction · 0.85
MultiplyByCostMethod · 0.80
estimateSizeFunction · 0.70
MultiplyMethod · 0.65
MultiplyByCostFactorMethod · 0.45

Tested by

no test coverage detected