arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2304.10778cs.SE
收藏

评估AI辅助代码生成工具的代码质量:基于GitHub Copilot、Amazon CodeWhisperer和ChatGPT的实证研究

Evaluating the Code Quality of AI-Assisted Code Generation Tools: An Empirical Study on GitHub Copilot, Amazon CodeWhisperer, and ChatGPT

Burak Yetiştiren, Işık Özsoy, Miray Ayerdem, Eray Tüzün

AI总结:

本研究基于HumanEval数据集,从有效性、正确性、安全性、可靠性和可维护性五个维度比较了GitHub Copilot、Amazon CodeWhisperer和ChatGPT的代码生成质量,发现ChatGPT正确率最高且技术债务适中,为开发者选择最佳工具提供了实证依据。

摘要:

背景:AI辅助代码生成工具在软件工程中日益普及,能够根据自然语言提示或部分代码输入生成代码。这些工具的典型例子包括GitHub Copilot、Amazon CodeWhisperer和OpenAI的ChatGPT。目标:本研究旨在比较这些主流代码生成工具在代码质量指标方面的表现,包括代码有效性、代码正确性、代码安全性、代码可靠性和代码可维护性,以识别其优势与不足。方法:我们使用基准HumanEval Dataset评估GitHub Copilot、Amazon CodeWhisperer和ChatGPT的代码生成能力,并根据提出的代码质量指标对生成的代码进行评估。结果:我们的分析显示,最新版本的ChatGPT、GitHub Copilot和Amazon CodeWhisperer生成正确代码的比例分别为65.2%、46.3%和31.1%。相比之下,较新版本的GitHub Copilot和Amazon CodeWhisperer显示出改进率,GitHub Copilot为18%,Amazon CodeWhisperer为7%。考虑代码异味,平均技术债务为:ChatGPT 8.9分钟,GitHub Copilot 9.1分钟,Amazon CodeWhisperer 5.6分钟。结论:本研究突出了部分最受欢迎代码生成工具的优缺点,为从业者提供了宝贵见解。通过比较这些生成器,我们的结果可帮助从业者针对特定任务选择最佳工具,从而优化其决策过程。

英文摘要:

Context: AI-assisted code generation tools have become increasingly prevalent in software engineering, offering the ability to generate code from natural language prompts or partial code inputs. Notable examples of these tools include GitHub Copilot, Amazon CodeWhisperer, and OpenAI's ChatGPT. Objective: This study aims to compare the performance of these prominent code generation tools in terms of code quality metrics, such as Code Validity, Code Correctness, Code Security, Code Reliability, and Code Maintainability, to identify their strengths and shortcomings. Method: We assess the code generation capabilities of GitHub Copilot, Amazon CodeWhisperer, and ChatGPT using the benchmark HumanEval Dataset. The generated code is then evaluated based on the proposed code quality metrics. Results: Our analysis reveals that the latest versions of ChatGPT, GitHub Copilot, and Amazon CodeWhisperer generate correct code 65.2%, 46.3%, and 31.1% of the time, respectively. In comparison, the newer versions of GitHub CoPilot and Amazon CodeWhisperer showed improvement rates of 18% for GitHub Copilot and 7% for Amazon CodeWhisperer. The average technical debt, considering code smells, was found to be 8.9 minutes for ChatGPT, 9.1 minutes for GitHub Copilot, and 5.6 minutes for Amazon CodeWhisperer. Conclusions: This study highlights the strengths and weaknesses of some of the most popular code generation tools, providing valuable insights for practitioners. By comparing these generators, our results may assist practitioners in selecting the optimal tool for specific tasks, enhancing their decision-making process.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑