Skip to content

Commit 68812d6

Browse files
autoantwortclaude
andcommitted
Use a deeper call chain with fewer files in the performance test
The test with 2000 files hit the timeout on slow CI runners even with the fix. 100 files with --max-ctu-depth=4 take 0.1 s with the fix and more than a minute without it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 1b8881c commit 68812d6

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

‎test/cli/performance_test.py‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -482,21 +482,22 @@ def test_large_number_of_violations_and_suppressions(tmpdir):
482482

483483
@pytest.mark.timeout(20)
484484
def test_slow_ctu_header_included_by_many_files(tmpdir):
485-
# whole program analysis was very slow when a header with nested calls is included by many files
485+
# 15292: whole program analysis was very slow when a header with nested calls is included by many files
486486
with open(os.path.join(tmpdir, 'header.h'), 'wt') as f:
487-
f.write("inline int digit(const char *s, int i) { return s[i] - '0'; }\n"
488-
"inline int two(const char *s, int i) { return digit(s, i) * 10 + digit(s, i + 1); }\n"
489-
"inline int four(const char *s, int i) { return two(s, i) * 100 + two(s, i + 2); }\n")
487+
f.write("inline int f0(const char *s, int i) { return s[i] - '0'; }\n")
488+
for level in range(1, 5):
489+
f.write(f'inline int f{level}(const char *s, int i) {{ return f{level - 1}(s, i) + f{level - 1}(s, i + 1); }}\n')
490490
files = []
491-
for i in range(2000):
491+
for i in range(100):
492492
filename = f'test{i}.cpp'
493493
with open(os.path.join(tmpdir, filename), 'wt') as f:
494494
f.write('#include "header.h"\n'
495-
f'int f{i}(void) {{ return four("2026", 0); }}\n')
495+
f'int g{i}(void) {{ return f4("0123456789abcdef", 0); }}\n')
496496
files.append(filename)
497497
build_dir = os.path.join(tmpdir, 'b1')
498498
os.mkdir(build_dir)
499-
ret, stdout, stderr = cppcheck(['-q', '-j2', f'--cppcheck-build-dir={build_dir}'] + files, cwd=tmpdir) # should not take more than ~3 seconds
499+
args = ['-q', '-j2', '--max-ctu-depth=4', f'--cppcheck-build-dir={build_dir}'] + files
500+
ret, stdout, stderr = cppcheck(args, cwd=tmpdir) # should not take more than ~1 second
500501
assert ret == 0, stdout
501502
assert stdout == ''
502503
assert stderr == ''

0 commit comments

Comments
 (0)