Rethinking Code Complexity Through the Lens of Large Language Models
Chen Xie, Yuling Shi, Xiaodong Gu, Beijun Shen

TL;DR
This paper introduces LM-CC, a new code complexity metric based on LLMs' perceived difficulty, which outperforms traditional metrics in correlating with LLM performance and improving code understanding tasks.
Contribution
The paper proposes LM-CC, a novel complexity metric derived from LLMs' semantic processing, addressing the mismatch of classical metrics with LLM-perceived difficulty.
Findings
Traditional metrics show no consistent correlation with LLM performance.
LM-CC correlates more strongly with LLM performance than classical metrics.
Lowering LM-CC improves LLM-based code understanding tasks.
Abstract
Code complexity metrics such as cyclomatic complexity have long been used to assess software quality and maintainability. With the rapid advancement of large language models (LLMs) on code understanding and generation tasks, an important yet underexplored question arises: do these traditional complexity metrics meaningfully characterize the difficulty LLMs experience when processing code? In this work, we empirically demonstrate that, after controlling for code length, classical metrics exhibit no consistent correlation with LLM performance, revealing a fundamental mismatch with model-perceived difficulty. To address this gap, we propose LM-CC, a novel code complexity metric designed from the perspective of LLMs. The core premise of LM-CC is that LLM-perceived difficulty is driven by the nonlinearity of program semantics. Accordingly, we decompose programs into semantic units based on…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsSoftware Engineering Research · Text Readability and Simplification · Software System Performance and Reliability
