arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2605.27981cs.AI
收藏

STAB:面向算法瓶颈的规约驱动测试

STAB: Specification-driven Testing for Algorithmic Bottlenecks

Yonsei University(延世大学)

Soohan Lim, Joonghyuk Hahn, Hyundong Jin, Yo-Sub Han

AI总结:

提出STAB流水线,通过约束饱和与对抗场景注入,从自然语言问题规约生成暴露算法瓶颈的测试用例,显著提升测试用例对瓶颈的检测率。

摘要:

评估算法代码的效率需要能够暴露运行时瓶颈的测试用例。先前的方法通过增加输入规模或生成使给定实现运行缓慢的代码特定输入来生成效率测试用例。因此,它们没有处理驱动算法最坏情况的结构性输入条件。我们引入STAB,一个规约驱动的流水线,仅从自然语言问题规约生成暴露算法瓶颈的测试用例。STAB将任务分为约束边界最大化和对抗结构注入两部分。(i) 约束饱和器提取约束,并通过基于规则的饱和及对相关变量的CP-SAT优化来解析大的可接受规模赋值。(ii) 对抗场景注入器使用关键词匹配和K近邻(KNN)从策划的场景目录中检索实现级别的对抗构造原则。STAB将问题规约、解析的边界和检索到的构造原则编码为结构化生成规约,LLM据此合成Python测试用例生成器。在CodeContests上,STAB将生成测试用例中暴露算法瓶颈的比例从开源LLM平均50.43%提升至73.45%,从闭源LLM平均57.45%提升至71.85%,在Python、Java和C++上均有一致提升。我们的代码可在https://github.com/suhanmen/STAB获取。

英文摘要:

Evaluating the efficiency of algorithmic code requires test cases that expose runtime bottlenecks. Previous methods generate efficiency test cases either by increasing input size or by generating code-specific inputs that make the given implementation run slowly. Consequently, they do not address the structural input conditions that drive the algorithmic worst case. We introduce STAB, a specification-driven pipeline that generates test cases that expose algorithmic bottlenecks from a natural-language problem specification alone. STAB separates the task into constraint-bound maximization and adversarial structure injection. (i) The constraint saturator extracts constraints and resolves large admissible size assignments using rule-based saturation and CP-SAT optimization over related variables. (ii) The adversarial scenario injector retrieves implementation-level adversarial construction principles from a curated scenario catalog using keyword matching and K-nearest neighbors (KNN). STAB encodes the problem specification, resolved boundary, and retrieved construction principles into a structured generation specification, from which the LLM synthesizes a Python test case generator. On CodeContests, STAB raises the rate of generated test cases that expose algorithmic bottlenecks from 50.43% to 73.45% on average across open-source LLMs and from 57.45% to 71.85% on average across closed-source LLMs, with consistent gains across Python, Java, and C++. Our code is available at https://github.com/suhanmen/STAB.

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

↑