Repository navigation
[TEST] Speed up slow class tests by removing redundant work (#4854) - #9696
Conversation
These tests re-ran expensive, deterministic computations many times over the same input while only reading different trivial properties of the identical result. Compute each distinct configuration once and reuse it; no assertion or expected value changes. - FLASHDeconvAlgorithm_test: ran the full (deterministic) deconvolution 20x on the same input across the "Phase 1" sections. The TOPDOWN module has no randomness, so hoist one shared default run and one shared FDR run and repoint the read-only sections at them (20 -> 8 runs). All distinct configurations (RNA, gaussian merging, FDR) and the cross-run determinism guards are preserved. ~213s -> ~60s (Release). - OPXLHelper_test: the O(n^2) enumerateCrossLinksAndMasses was run 3x with byte-identical inputs; enumerate once at file scope and reuse (copies where filterPrecursorsByTags mutates in place). - IsobaricChannelExtractor_test: IsobaricChannelExtractor_6.mzML was parsed from disk 6x into fresh PeakMaps; parse once into a shared const map and alias it (read-only) in each section. - MultiplexClustering_test: drop a full cluster() call in the constructor section whose result was never asserted (the cluster() section below already exercises and checks it). Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughFour unit test files were refactored to reuse shared inputs and precomputed results instead of repeating expensive setup and execution. The changes affect FLASHDeconvAlgorithm, IsobaricChannelExtractor, MultiplexClustering, and OPXLHelper tests. ChangesFLASHDeconvAlgorithm test refactor
IsobaricChannelExtractor shared PeakMap refactor
MultiplexClustering constructor test simplification
OPXLHelper precursor enumeration reuse
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/tests/class_tests/openms/source/FLASHDeconvAlgorithm_test.cpp`:
- Around line 313-336: Replace the boolean assertions in
FLASHDeconvAlgorithm_test with the preferred TEST_TRUE/TEST_FALSE helpers,
especially in the Output validation sections. Update the checks on
spec.getScanNumber() and feature.avg_mass to use TEST_TRUE, and remove the
tautological default_features.size() >= 0 assertion since it can never fail; if
you need to verify feature presence, assert a meaningful condition against
default_features or its contents instead.
In `@src/tests/class_tests/openms/source/IsobaricChannelExtractor_test.cpp`:
- Around line 77-80: The shared load of IsobaricChannelExtractor_6.mzML should
not happen before the first section because it bypasses the per-section
START_SECTION try/catch handling. Move the PeakMap ic6_shared initialization and
the MzMLFile().load call into a dedicated START_SECTION setup block or a small
helper invoked from within a section so any parse/file failure only fails that
subtest. Keep the shared variable available to the later sections that reuse it.
In `@src/tests/class_tests/openms/source/OPXLHelper_test.cpp`:
- Around line 89-93: The shared precursors vector is being reordered by
OPXLDataStructs::XLPrecursorComparator, but
spectrum_precursor_correction_positions is left in the original order, so the
pair loses alignment. In the OPXLHelper_test setup where
enumerateCrossLinksAndMasses is reused, either sort a local copy of precursors
or apply the same ordering to spectrum_precursor_correction_positions before the
later filterPrecursorsByTags section so each precursor stays matched with its
correction position.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 56647df9-0ca5-4e90-a817-0c3d5fb01f8b
📒 Files selected for processing (4)
src/tests/class_tests/openms/source/FLASHDeconvAlgorithm_test.cppsrc/tests/class_tests/openms/source/IsobaricChannelExtractor_test.cppsrc/tests/class_tests/openms/source/MultiplexClustering_test.cppsrc/tests/class_tests/openms/source/OPXLHelper_test.cpp
…aligned FLASHDeconvAlgorithm_test: - Use TEST_TRUE/TEST_FALSE for boolean assertions in the Output Validation sections (spec.getScanNumber(), feature.avg_mass, pg.getMonoMass(), found_peak_groups) instead of TEST_EQUAL(<bool>, true). - Replace the tautological TEST_EQUAL(default_features.size() >= 0, true) (size() is unsigned, so it can never fail) with the meaningful TEST_FALSE(default_features.empty()); the default run finds features on this input (as the void run() section already asserts). OPXLHelper_test: - The shared 'precursors' was sorted in place while 'spectrum_precursor_correction_positions' was left unsorted, so the filterPrecursorsByTags section reused a misaligned pair. Sort a local copy inside the buildCandidates section (the only consumer needing sorted precursors) so the shared vectors stay index-aligned for the filter test. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Closes #4854.
Context
The 2020 issue lists Windows-Debug runtimes. Much has already improved on
develop: several named offenders were removed (CompNovo,PeakPickerCWT) or renamed, and the diagnosedstd::endl-flush cause is already handled (theClassTestframework and mzML writer use'\n'/buffered writes and only print on failure).Measuring current standalone runtimes, one test dominates every other pure-OpenMS class test by two orders of magnitude. These changes remove redundant, deterministic recomputation from the heaviest tests. No assertion or expected value changes — each distinct configuration is still exercised exactly as before.
Changes
run()s_6.mzMLparsed 6× → 1×cluster()removed[WIP]PR) re-ran the full deconvolution 20× on the same input, each only reading a different trivial property of the identical result. TheTOPDOWNmodule has no randomness (sorun()is deterministic, which the test's own consistency sections already assert), so this hoists one shared default run and one shared FDR run and repoints the read-only sections at them. All distinct configs (RNA averagine, gaussian merging, FDR) and the cross-run determinism guards are kept. 213 s → ~60 s (Release).enumerateCrossLinksAndMassesran 3× with byte-identical inputs → enumerate once and reuse (copies wherefilterPrecursorsByTagsmutates in place).IsobaricChannelExtractor_6.mzMLwas parsed from disk 6× into freshPeakMaps → parse once into a shared const map, aliased read-only in each section (extractChannelstakesconst PeakMap&).cluster()call in the constructor-only section whose result was never asserted.Notes
On Linux Release the three secondary tests are already ~0.2 s (small test data); their payoff is Windows-Debug-specific, where per-op cost is 100–300× and they map onto the issue's own 75 s / 26 s entries. FLASHDeconv is the decisive, cross-platform win. All four tests were rebuilt and pass with identical outputs. The remaining suite hotspots are external-tool adapters (Comet/Sage/Percolator/Luciphor), which aren't OpenMS-code-optimizable.
🤖 Generated with Claude Code
Summary by CodeRabbit