基于学习的代码复杂度预测方法
Learning based Methods for Code Runtime Complexity Prediction
摘要:
预测程序代码的运行时复杂度是一项艰巨的任务。事实上,即使对于人类来说,也需要对算法进行细致的分析和全面的了解,才能在给定任何代码的情况下,高保真地预测时间复杂度。根据图灵的停机问题证明,估计代码复杂度在数学上是不可能的。然而,这样一个任务的近似解决方案可以帮助开发人员获得代码效率的实时反馈。在这项工作中,我们将这个问题建模为一个机器学习任务,并通过深入的分析来检查其可行性。由于缺乏任何开源数据集,我们提出了自己的注释数据集CoRCoD:代码复杂性数据集,从在线法官中提取。我们使用两种不同的方法建立基线:特征工程和代码嵌入,以实现最先进的结果并比较它们的性能。这样的解决方案在潜在的应用中非常有用,例如自动分级编码任务,用于静态代码分析的IDE集成工具等。
英文摘要:
Predicting the runtime complexity of a programming code is an arduous task. In fact, even for humans, it requires a subtle analysis and comprehensive knowledge of algorithms to predict time complexity with high fidelity, given any code. As per Turing's Halting problem proof, estimating code complexity is mathematically impossible. Nevertheless, an approximate solution to such a task can help developers to get real-time feedback for the efficiency of their code. In this work, we model this problem as a machine learning task and check its feasibility with thorough analysis. Due to the lack of any open source dataset for this task, we propose our own annotated dataset CoRCoD: Code Runtime Complexity Dataset, extracted from online judges. We establish baselines using two different approaches: feature engineering and code embeddings, to achieve state of the art results and compare their performances. Such solutions can be widely useful in potential applications like automatically grading coding assignments, IDE-integrated tools for static code analysis, and others.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。