Overview
Thestress command verifies that your solution executes within the specified time and memory limits across multiple randomly generated test cases. Unlike cmp, it doesn’t verify correctness against another solution—it only checks performance.
Use
stress when you’re confident your solution is correct but want to ensure it runs fast enough for contest constraints.Basic Usage
Required Parameters
Your solution file to stress test. Can be any supported language (C++, Java, Python, Rust, Go, C, Kotlin).Short form:
-tRandom test case generator file that produces input data.Short form:
-gDefault: "" (empty - can use --prefix instead)The generator and prefix options are mutually exclusive. Use either
--gen-file for random generation or --prefix to run existing test cases.Optional Parameters
Number of test cases to generate and run.Alias:
--tcMaximum execution time per test case in milliseconds.Alias:
--toutMemory limit in bytes (default is 1GB).Alias:
--mlPath prefix for existing test case files. Use this to stress test against pre-existing test cases.Short form:
-pConflicts with: --gen-fileControl Flags
Stop execution immediately when a TLE (Time Limit Exceeded) or RTE (Runtime Error) occurs.Aliases:
--break, -bSave Options
Save only test cases that fail (TLE, RTE, MLE states).
Save all test cases regardless of their result.
Run Filters
Use these flags to run specific subsets of previously saved test cases:Run all saved test cases.
Run only test cases that previously passed (Accepted status).
Run only test cases that previously failed with Wrong Answer.
Run only test cases that previously exceeded time limit.
Run only test cases that previously exceeded memory limit.
Run only test cases that previously had runtime errors.
Examples
Basic Stress Test
Detect TLE Cases
Strict Time Constraints
Test with strict competitive programming time limits (1 second):Memory-Intensive Problems
Set a custom memory limit (256MB):Using Existing Test Cases
Run stress tests against pre-generated test files:Complete Example with Generator
Here’s a complete stress testing scenario:Comprehensive Testing Session
Save all test cases for later analysis:Understanding Test Results
QuickTest displays real-time results with status indicators:- AC - Accepted (passed within time/memory limits)
- TLE - Time Limit Exceeded
- MLE - Memory Limit Exceeded
- RTE - Runtime Error
Since
stress doesn’t compare outputs, you won’t see WA (Wrong Answer) status. Use the cmp command if you need correctness verification.When to Use Stress
Performance Testing
Verify your solution meets time constraints for large inputs
Optimization Validation
Confirm optimizations actually improve runtime
Memory Profiling
Test memory-intensive solutions against limits
Regression Testing
Ensure code changes don’t introduce performance issues