Java中排序算法的能量与时间复杂度
Energy and Time Complexity for Sorting Algorithms in Java
AI总结:
本文通过Java环境下四种排序算法、136种组合和12960次测量,发现时间复杂度与CPU能耗强相关,可作为节能算法选择依据。
摘要:
本文研究排序算法中时间复杂度与能耗之间的关系,重点关注用Java实现的常用算法:Bubble Sort(冒泡排序)、Counting Sort(计数排序)、Merge Sort(归并排序)和Quick Sort(快速排序)。理解这一关系的重要性源于信息与通信技术系统日益增长的能源需求,以及软件优化为提升能效作出贡献的潜力。如果发现时间复杂度与能耗之间存在强相关性,将增强软件开发人员构建节能应用的能力。这项定量研究在支持Java的系统的单个内核上,考察四种所选排序算法在不同输入规模(25000至100万)和输入顺序类型(最佳、最坏和随机情况)下的执行情况。输入规模根据该类型的最大执行时间进行调整,由此产生136种组合,共计12960次测量。挂钟时间和CPU能耗使用Intel的RAPL进行测量。研究采用统计分析检验时间复杂度、挂钟时间与能耗之间的相关性。研究发现,在所测试的排序算法中,时间复杂度与能耗之间存在强相关性。Counting Sort、Merge Sort和Quick Sort能耗中超过99%的方差取决于其时间复杂度。Bubble Sort能耗中超过94%的方差取决于其时间复杂度。结果证实,在顺序排序算法中,时间复杂度可作为能耗的可靠预测指标。这一发现可指导软件开发人员通过考虑时间复杂度来选择节能算法。
英文摘要:
The article investigates the relationship between time complexity and energy consumption in sorting algorithms, focusing on commonly-used algorithms implemented in Java: Bubble Sort, Counting Sort, Merge Sort, and Quick Sort. The significance of understanding this relationship is driven by the increasing energy demands of Information and Communication Technology systems and the potential for software optimization to contribute to energy efficiency. If we find a strong correlation between time complexity and energy usage, it would enhance the ability of software developers to create energy-efficient applications. This quantitative study researches the execution of four selected sorting algorithms with input varying over input sizes (25000 to 1 million) and input order types (best, worst, and random cases) on a single kernel in a Java-enabled system. The input size is adjusted according to the type's maximum execution time, resulting in 136 combinations, totalling 12960 measurements. Wall time and the CPU energy consumption is measured using Intel's RAPL. Statistical analysis are used to examine the correlations between time complexity, wall time, and energy consumption. The study finds a strong correlation between time complexity and energy consumption for the sorting algorithms tested. More than 99% of the variance in energy consumption for Counting Sort, Merge Sort, and Quick Sort depend on their time complexities. More than 94% of the variance in energy consumption for Bubble Sort depends on its time complexity. The results affirm that time complexity can serve as a reliable predictor of energy consumption in sequential sorting algorithms. This discovery could guide software developers in choosing energy-efficient algorithms by considering time complexities.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。