arXiv:2608.30248cs.SEAug 2026

Manuscript Offprint

arXiv:2608.30248

DSEffi-Bench: Demystifying Large Language Models' Capability in Efficient Data Science Code Generation

Zhihao Gong, Junzhe Yu, Dong Huang, Zeyu Sun, Jie M. Zhang, Dan Hao

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Current data science (DS) code generation benchmarks equate correctness with quality, overlooking execution time differences that span orders of magnitude between correct solutions. We introduce DSEffi-Bench, the first benchmark specifically targeting execution efficiency in LLM-generated DS code, comprising 1,000 instances across 10+ DS libraries with stress-testing harnesses and human-validated references. Evaluating 16 models across 3 tiers, we find that correctness alone fails to characterize efficiency: GPT-5.4 leads in correctness (Pass, 66.9%) but its efficiency score (B|P, 71.7%) nearly matches GPT-5.4-mini (71.6%), which solves 47 fewer tasks; Kimi-K2.5 ranks lowest in correctness among frontier models (40.2%) yet achieves the highest efficiency score (73.6%) across all 16 models. A human-annotated five-category taxonomy reveals that 79.1% of efficiency deficits extend beyond algorithmic complexity to domain-specific root causes, with distinct failure profiles across model tiers and libraries. Two exploratory experiments provide initial evidence that these diagnostics can guide improvement, yielding up to +14.7% efficiency gains via taxonomy-guided optimization and approaching Claude-Opus-4.6 Best@3 in efficiency at 13.0× lower cost via library-conditioned routing. Code and data are available at https://github.com/Albert-Gong/DSEffi-Bench.

1 Introduction

In data science (DS) coding (Lai et al., 2023), programmers write code to solve DS problems such as statistical modeling, numerical optimization, and deep learning. As LLM-assisted code generation (Chen et al., 2021; Jain et al., 2025) advances, DS coding has emerged as one of its most active application domains (Sun et al., 2026).

Figure

Figure 1: Functional correctness (Pass, %) vs. execution efficiency (B|P, %) for 16 models on DSEffi-Bench.

DS coding by nature differs from general-purpose programming. The domain knowledge is extensive and encapsulated in highly optimized library APIs (Huang et al., 2022; Wang et al., 2026). Writing authentic DS code demands selecting the right primitives, not merely implementing the logic from scratch. Prior benchmarks such as ExeDS (Huang et al., 2022), DS-1000 (Lai et al., 2023) and DSCodeBench (Ouyang et al., 2026) curate realistic DS tasks to evaluate LLM capability. All of them reveal uneven performance across libraries and observe that larger models tend to outperform smaller ones in correctness.

However, current benchmarks evaluate functional correctness exclusively and leave execution efficiency (Niu et al., 2024; Gong et al., 2026) unexamined. In DS coding, efficiency depends critically on API selection: functionally equivalent paths can differ by orders of magnitude in execution time. For instance, df.groupby('k').cummax() and df.groupby('k').apply(lambda g: g.cummax()) produce identical output yet differ by an order of magnitude because the latter incurs Python-level groupwise callback overhead. LLMs are particularly susceptible to such gaps (Xue et al., 2025), as they default to general-purpose patterns over library-specific optimized primitives. Correctness-only evaluation cannot surface this systematic weakness.

∗^{*}Equal contribution.

†^{\dagger}Corresponding author.

To address this gap, we introduce DSEffi-Bench, the first execution efficiency benchmark for evaluating LLM-based DS code generation. DSEffi-Bench treats correctness and efficiency as two distinct capabilities and exposes their interplay through a dedicated evaluation protocol. Concretely, we source efficiency-oriented Stack Overflow (SO) posts and apply a quality-gated four-stage pipeline that progressively filters 17,257 candidates down to 1,000 human-validated instances. Each instance contains a problem description, an evaluation harness covering both correctness and stress test cases, and a human-validated reference solution.

Using DSEffi-Bench, we evaluate 16 models spanning 3 tiers. First, correctness and efficiency are not aligned. GPT-5.4 achieves the highest correctness (Pass, 66.9%), yet its efficiency on solved tasks (B|P, 71.7%) is virtually identical to GPT-5.4-mini (71.6%), which solves 47 fewer tasks. Conversely, Kimi-K2.5 solves the fewest tasks among frontier models (40.2%) yet attains the highest B|P (73.6%) across all 16 models. Second, our five-category taxonomy shows that 79.1% of efficiency failures extend beyond algorithmic complexity to domain-specific root causes. These failures are tier-dependent: loop-to-vectorization gaps rise from 7.3% in Closed Frontier LLMs to 29.6% in Open Coder LLMs, while overhead-aware stack matching (OSM) declines from 29.3% to 9.3%. Third, two exploratory experiments show that these diagnostics can guide improvement: taxonomy-guided optimization prompting raises efficiency by up to +14.7%, and library-conditioned routing among open models approaches Claude-Opus-4.6 Best@3 in efficiency at 13.0× lower cost.

This work makes the following contributions: 1) Benchmark. We propose DSEffi-Bench, the first execution efficiency benchmark for DS code generation, comprising 1,000 human-validated instances across 10+ libraries. 2) Diagnosis. We conduct a systematic evaluation and develop a five-category taxonomy that localizes 79.1% of efficiency deficits to domain-specific root causes. 3) Remedy. We explore taxonomy-guided optimization and library-aware routing and show their potential to improve efficiency.