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)
| 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. |
| 818 | func 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. |
no test coverage detected