aboutsummaryrefslogtreecommitdiff
path: root/tools/perf/scripts/python/stackcollapse.py
diff options
context:
space:
mode:
authorKuan-Wei Chiu <[email protected]>2024-01-13 11:13:51 +0800
committerAndrew Morton <[email protected]>2024-02-22 15:38:52 -0800
commitdb946a42226052a13fbce8757ff77b3107dd2030 (patch)
tree2f0d5181a6add3dc52468219e5be5a4528f4ef66 /tools/perf/scripts/python/stackcollapse.py
parent6db9d317833dd89d666ca0373c7b60f413bca9eb (diff)
lib/sort: optimize heapsort for equal elements in sift-down path
Patch series "lib/sort: Optimize the number of swaps and comparisons". This patch series aims to optimize the heapsort algorithm, specifically targeting a reduction in the number of swaps and comparisons required. This patch (of 2): Currently, when searching for the sift-down path and encountering equal elements, the algorithm chooses the left child. However, considering that the height of the right subtree may be one less than that of the left subtree, selecting the right child in such cases can potentially reduce the number of comparisons and swaps. For instance, when sorting an array of 10,000 identical elements, the current implementation requires 247,209 comparisons. With this patch, the number of comparisons can be reduced to 227,241. Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Kuan-Wei Chiu <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
Diffstat (limited to 'tools/perf/scripts/python/stackcollapse.py')
0 files changed, 0 insertions, 0 deletions