Using AI-Driven Code Refactoring to Reduce Carbon Emissions of Software Development
摘要
With the escalating urgency to combat climate change, energy consumption in software development has become a significant concern. Leveraging AI-driven techniques, particularly in code refactoring, has the potential to optimize software for reduced energy consumption and environmental impact. How effective is an AI-driven code refactoring tool in reducing software-related carbon emissions, and what measures can enhance its impact on mitigating climate change? By using chatGPT 3.5 for code refactoring, verifying the results, and measuring the carbon emissions and runtime of each file, that question is answered. Improvements are found in both runtime and carbon emissions. Furthermore, a linear relationship between runtime and carbon emissions was confirmed. Machine learning (ML) code examples improved on average by 45% for runtime, and 47% for carbon emissions. While non-ML examples improved on average by 24% for runtime, and 28% for carbon emissions. The positive results demonstrate that it is effective to use AI-driven code refactoring to reduce carbon emissions produced by software development.