scirs2-interpolate 0.4.1

Interpolation module for SciRS2 (scirs2-interpolate)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
//! Helper functions and utilities for production stress testing
//!
//! This module contains utility functions for creating test results, calculating metrics,
//! and other common operations used throughout the stress testing system.

use super::generators::*;
use super::types::*;
use crate::error::{InterpolateError, InterpolateResult};
use crate::traits::InterpolationFloat;
use scirs2_core::ndarray::Array1;
use std::time::{Duration, Instant};

impl<T: InterpolationFloat + std::panic::RefUnwindSafe> ProductionStressTester<T> {
    /// Estimate memory usage for a given data size
    pub fn estimate_memory_usage(&self, size: usize) -> u64 {
        // Rough estimation: 2 arrays of T + overhead
        (size * 2 * std::mem::size_of::<T>() + 1024) as u64
    }

    /// Calculate performance metrics from execution times
    pub fn calculate_performance_metrics(
        &self,
        execution_times: &[Duration],
        baseline: Option<&BaselinePerformance>,
    ) -> StressPerformanceMetrics {
        if execution_times.is_empty() {
            return StressPerformanceMetrics::default();
        }

        let total_time: Duration = execution_times.iter().sum();
        let mean_time = total_time / (execution_times.len() as u32);
        let min_time = *execution_times
            .iter()
            .min()
            .unwrap_or(&Duration::from_millis(0));
        let max_time = *execution_times
            .iter()
            .max()
            .unwrap_or(&Duration::from_millis(0));

        let degradation_factor = baseline.map(|b| {
            if b.execution_time.as_nanos() > 0 {
                mean_time.as_nanos() as f64 / b.execution_time.as_nanos() as f64
            } else {
                1.0
            }
        });

        let throughput = if mean_time.as_secs_f64() > 0.0 {
            Some(1.0 / mean_time.as_secs_f64())
        } else {
            None
        };

        StressPerformanceMetrics {
            mean_execution_time: mean_time,
            max_execution_time: max_time,
            min_execution_time: min_time,
            degradation_factor,
            throughput,
            memory_efficiency: Some(0.8), // Placeholder
        }
    }

    /// Create a success result for a test
    pub fn create_success_result(
        &self,
        test_name: &str,
        data_size: usize,
        execution_time: Duration,
        category: StressTestCategory,
    ) -> StressTestResult {
        StressTestResult {
            test_name: test_name.to_string(),
            category,
            input_characteristics: format!("{} data points", data_size),
            status: TestStatus::Passed,
            execution_time,
            performance: self.calculate_performance_metrics(
                &[execution_time],
                self.baseline_performance.as_ref(),
            ),
            error_info: None,
            memory_usage: MemoryUsageStats {
                peak_usage: self.estimate_memory_usage(data_size),
                average_usage: self.estimate_memory_usage(data_size),
                initial_usage: 0,
                final_usage: 0,
                memory_leaked: 0,
            },
            duration: execution_time,
            issues: Vec::new(),
            recommendations: Vec::new(),
        }
    }

    /// Create error result for failed tests
    pub fn create_error_result(
        &self,
        test_name: &str,
        data_size: usize,
        error: InterpolateError,
        category: StressTestCategory,
    ) -> StressTestResult {
        StressTestResult {
            test_name: test_name.to_string(),
            category,
            input_characteristics: format!("Error case with {} data points", data_size),
            execution_time: Duration::from_millis(1),
            status: TestStatus::Error,
            performance: StressPerformanceMetrics::default(),
            error_info: Some(ErrorInfo {
                error_type: "InterpolateError".to_string(),
                error_message: error.to_string(),
                iteration: Some(0),
                data_size: Some(data_size),
                recovery_attempted: false,
                recovery_successful: false,
            }),
            memory_usage: MemoryUsageStats::default(),
            duration: Duration::from_millis(1),
            issues: vec![StressTestIssue {
                description: "Test failed due to error".to_string(),
                severity: IssueSeverity::High,
                production_impact: ProductionImpact::Major,
                suggested_fix: Some("Add error handling for this scenario".to_string()),
                iteration: Some(0),
            }],
            recommendations: vec![
                "Investigate error cause and add appropriate handling".to_string()
            ],
        }
    }

    /// Create panic result for tests that panicked
    pub fn create_panic_result(
        &self,
        test_name: &str,
        data_size: usize,
        category: StressTestCategory,
    ) -> StressTestResult {
        StressTestResult {
            test_name: test_name.to_string(),
            category,
            input_characteristics: format!("Panic case with {} data points", data_size),
            execution_time: Duration::from_millis(1),
            status: TestStatus::Failed,
            performance: StressPerformanceMetrics::default(),
            error_info: Some(ErrorInfo {
                error_type: "Panic".to_string(),
                error_message: "Test panicked during execution".to_string(),
                iteration: Some(0),
                data_size: Some(data_size),
                recovery_attempted: false,
                recovery_successful: false,
            }),
            memory_usage: MemoryUsageStats::default(),
            duration: Duration::from_millis(1),
            issues: vec![StressTestIssue {
                description: "Test caused panic - critical production risk".to_string(),
                severity: IssueSeverity::Critical,
                production_impact: ProductionImpact::Blocking,
                suggested_fix: Some("Add panic handling and input validation".to_string()),
                iteration: Some(0),
            }],
            recommendations: vec![
                "Critical: Fix panic condition before production deployment".to_string()
            ],
        }
    }

    /// Generate recommendations for a specific pathological pattern
    pub fn generate_recommendations_for_pattern(&self, pattern: &str) -> Vec<String> {
        match pattern {
            "constant" => vec![
                "Consider adding validation for constant data".to_string(),
                "Provide meaningful error messages for degenerate cases".to_string(),
            ],
            "duplicate_x" => vec![
                "Add input validation to detect duplicate x values".to_string(),
                "Consider data preprocessing options".to_string(),
            ],
            "extreme_y" => vec![
                "Add range checking for extreme values".to_string(),
                "Consider data normalization techniques".to_string(),
            ],
            "nan_inf" => vec![
                "Add robust NaN/infinity detection and handling".to_string(),
                "Provide clear error messages for invalid data".to_string(),
            ],
            "sparse" => vec![
                "Document minimum data density requirements".to_string(),
                "Consider alternative methods for sparse data".to_string(),
            ],
            "oscillatory" => vec![
                "Test with various interpolation methods".to_string(),
                "Consider adaptive sampling strategies".to_string(),
            ],
            "monotonic_extreme" => vec![
                "Verify numerical stability with extreme monotonic data".to_string(),
                "Consider logarithmic scaling for extreme ranges".to_string(),
            ],
            _ => vec!["Review numerical stability for this data pattern".to_string()],
        }
    }

    /// Enhanced numerical stability testing
    pub fn test_enhanced_numerical_stability(&mut self) -> InterpolateResult<()> {
        println!("Testing enhanced numerical stability...");

        // Test matrix conditioning
        let matrix_test = self.test_matrix_conditioning()?;
        self.results.push(matrix_test);

        // Test precision limits
        let precision_test = self.test_precision_limits()?;
        self.results.push(precision_test);

        // Test gradient stability
        let gradient_test = self.test_gradient_stability()?;
        self.results.push(gradient_test);

        // Test oscillatory stability
        let oscillatory_test = self.test_oscillatory_stability()?;
        self.results.push(oscillatory_test);

        // Test scaling stability
        let scaling_test = self.test_scaling_stability()?;
        self.results.push(scaling_test);

        Ok(())
    }

    /// Test matrix conditioning effects
    fn test_matrix_conditioning(&self) -> InterpolateResult<StressTestResult> {
        let start = Instant::now();

        // Create ill-conditioned data
        let (x, y) = create_duplicate_x_data(100)?;
        let x_query = Array1::linspace(
            T::from_f64(1.0).expect("Operation failed"),
            T::from_f64(9.0).expect("Operation failed"),
            10,
        );

        let result = crate::interp1d::cubic_interpolate(&x.view(), &y.view(), &x_query.view());
        let duration = start.elapsed();

        let mut issues = Vec::new();
        let status = match result {
            Ok(values) => {
                if values.iter().any(|v| !v.is_finite()) {
                    issues.push(StressTestIssue {
                        description: "Matrix conditioning produced non-finite results".to_string(),
                        severity: IssueSeverity::High,
                        production_impact: ProductionImpact::Major,
                        suggested_fix: Some("Improve matrix conditioning handling".to_string()),
                        iteration: None,
                    });
                    TestStatus::PassedWithWarnings
                } else {
                    TestStatus::Passed
                }
            }
            Err(_) => {
                issues.push(StressTestIssue {
                    description: "Matrix conditioning caused interpolation failure".to_string(),
                    severity: IssueSeverity::Medium,
                    production_impact: ProductionImpact::Minor,
                    suggested_fix: Some(
                        "Add graceful handling for ill-conditioned matrices".to_string(),
                    ),
                    iteration: None,
                });
                TestStatus::PassedWithWarnings
            }
        };

        Ok(StressTestResult {
            test_name: "matrix_conditioning".to_string(),
            category: StressTestCategory::NumericalStability,
            input_characteristics: "Ill-conditioned matrix data".to_string(),
            status,
            execution_time: duration,
            performance: self.calculate_performance_metrics(&[duration], None),
            error_info: None,
            memory_usage: MemoryUsageStats::default(),
            duration,
            issues,
            recommendations: vec![
                "Monitor matrix condition numbers in production".to_string(),
                "Consider regularization for ill-conditioned problems".to_string(),
            ],
        })
    }

    /// Test precision limits
    fn test_precision_limits(&self) -> InterpolateResult<StressTestResult> {
        let start = Instant::now();

        // Test with very small differences
        let (x, y) = create_edge_case_data(100, 0.0, f64::EPSILON * 100.0)?;
        let x_query = Array1::linspace(
            T::from_f64(f64::EPSILON).expect("Operation failed"),
            T::from_f64(f64::EPSILON * 50.0).expect("Operation failed"),
            10,
        );

        let result = crate::interp1d::linear_interpolate(&x.view(), &y.view(), &x_query.view());
        let duration = start.elapsed();

        let mut issues = Vec::new();
        let status = match result {
            Ok(values) => {
                if values.iter().any(|v| !v.is_finite()) {
                    issues.push(StressTestIssue {
                        description: "Precision limits caused numerical instability".to_string(),
                        severity: IssueSeverity::Medium,
                        production_impact: ProductionImpact::Minor,
                        suggested_fix: Some("Add epsilon-based tolerance checking".to_string()),
                        iteration: None,
                    });
                    TestStatus::PassedWithWarnings
                } else {
                    TestStatus::Passed
                }
            }
            Err(_) => TestStatus::Failed,
        };

        Ok(StressTestResult {
            test_name: "precision_limits".to_string(),
            category: StressTestCategory::NumericalStability,
            input_characteristics: "Near machine precision data".to_string(),
            status,
            execution_time: duration,
            performance: self.calculate_performance_metrics(&[duration], None),
            error_info: None,
            memory_usage: MemoryUsageStats::default(),
            duration,
            issues,
            recommendations: vec!["Document precision requirements for production data".to_string()],
        })
    }

    /// Test gradient stability
    fn test_gradient_stability(&self) -> InterpolateResult<StressTestResult> {
        let start = Instant::now();

        // Create data with steep gradients
        let (x, y) = create_rapid_change_data(1000)?;
        let x_query = Array1::linspace(
            T::from_f64(4.5).expect("Operation failed"),
            T::from_f64(5.5).expect("Operation failed"),
            20,
        );

        let result = crate::interp1d::cubic_interpolate(&x.view(), &y.view(), &x_query.view());
        let duration = start.elapsed();

        let mut issues = Vec::new();
        let status = match result {
            Ok(values) => {
                // Check for oscillations or overshoots
                let max_val = values.iter().fold(T::neg_infinity(), |acc, &x| acc.max(x));
                let min_val = values.iter().fold(T::infinity(), |acc, &x| acc.min(x));

                if max_val > T::from_f64(150.0).expect("Operation failed")
                    || min_val < T::from_f64(-50.0).expect("Operation failed")
                {
                    issues.push(StressTestIssue {
                        description: "Steep gradients caused interpolation overshoots".to_string(),
                        severity: IssueSeverity::Medium,
                        production_impact: ProductionImpact::Minor,
                        suggested_fix: Some("Consider monotonic interpolation methods".to_string()),
                        iteration: None,
                    });
                    TestStatus::PassedWithWarnings
                } else {
                    TestStatus::Passed
                }
            }
            Err(_) => TestStatus::Failed,
        };

        Ok(StressTestResult {
            test_name: "gradient_stability".to_string(),
            category: StressTestCategory::NumericalStability,
            input_characteristics: "Data with steep gradients".to_string(),
            status,
            execution_time: duration,
            performance: self.calculate_performance_metrics(&[duration], None),
            error_info: None,
            memory_usage: MemoryUsageStats::default(),
            duration,
            issues,
            recommendations: vec![
                "Monitor for interpolation overshoots with steep data".to_string()
            ],
        })
    }

    /// Test oscillatory stability
    fn test_oscillatory_stability(&self) -> InterpolateResult<StressTestResult> {
        let start = Instant::now();

        let (x, y) = create_oscillatory_data(1000)?;
        let x_query = Array1::linspace(
            T::from_f64(1.0).expect("Operation failed"),
            T::from_f64(9.0).expect("Operation failed"),
            100,
        );

        let result = crate::interp1d::cubic_interpolate(&x.view(), &y.view(), &x_query.view());
        let duration = start.elapsed();

        let status = match result {
            Ok(_) => TestStatus::Passed,
            Err(_) => TestStatus::Failed,
        };

        Ok(StressTestResult {
            test_name: "oscillatory_stability".to_string(),
            category: StressTestCategory::NumericalStability,
            input_characteristics: "Highly oscillatory data".to_string(),
            status,
            execution_time: duration,
            performance: self.calculate_performance_metrics(&[duration], None),
            error_info: None,
            memory_usage: MemoryUsageStats::default(),
            duration,
            issues: Vec::new(),
            recommendations: vec!["Consider adaptive sampling for oscillatory data".to_string()],
        })
    }

    /// Test scaling stability
    fn test_scaling_stability(&self) -> InterpolateResult<StressTestResult> {
        let start = Instant::now();

        let (x, y) = create_extreme_y_data(100)?;
        let x_query = Array1::linspace(
            T::from_f64(1.0).expect("Operation failed"),
            T::from_f64(9.0).expect("Operation failed"),
            10,
        );

        let result = crate::interp1d::linear_interpolate(&x.view(), &y.view(), &x_query.view());
        let duration = start.elapsed();

        let status = match result {
            Ok(_) => TestStatus::Passed,
            Err(_) => TestStatus::Failed,
        };

        Ok(StressTestResult {
            test_name: "scaling_stability".to_string(),
            category: StressTestCategory::NumericalStability,
            input_characteristics: "Extreme value scaling".to_string(),
            status,
            execution_time: duration,
            performance: self.calculate_performance_metrics(&[duration], None),
            error_info: None,
            memory_usage: MemoryUsageStats::default(),
            duration,
            issues: Vec::new(),
            recommendations: vec!["Consider data normalization for extreme ranges".to_string()],
        })
    }

    /// Test error message clarity
    pub fn test_error_message_clarity(&mut self) -> InterpolateResult<()> {
        println!("Testing error message clarity...");

        // Test empty data error messages
        let empty_test = self.test_empty_data_error_messages()?;
        self.results.push(empty_test);

        // Test dimension mismatch errors
        let dimension_test = self.test_dimension_mismatch_errors()?;
        self.results.push(dimension_test);

        // Test parameter validation errors
        let param_test = self.test_parameter_validation_errors()?;
        self.results.push(param_test);

        // Test numerical error messages
        let numerical_test = self.test_numerical_error_messages()?;
        self.results.push(numerical_test);

        Ok(())
    }

    /// Test empty data error messages
    fn test_empty_data_error_messages(&self) -> InterpolateResult<StressTestResult> {
        let (x, y) = create_empty_data()?;
        let x_query = Array1::from_vec(vec![T::from_f64(1.0).expect("Operation failed")]);

        let result = crate::interp1d::linear_interpolate(&x.view(), &y.view(), &x_query.view());

        let status = match result {
            Err(e) => {
                let error_msg = e.to_string();
                if error_msg.contains("empty") || error_msg.contains("zero") {
                    TestStatus::Passed
                } else {
                    TestStatus::PassedWithWarnings
                }
            }
            Ok(_) => TestStatus::Failed,
        };

        Ok(StressTestResult {
            test_name: "empty_data_error_clarity".to_string(),
            category: StressTestCategory::ErrorHandling,
            input_characteristics: "Empty data arrays".to_string(),
            status,
            execution_time: Duration::from_millis(1),
            performance: StressPerformanceMetrics::default(),
            error_info: None,
            memory_usage: MemoryUsageStats::default(),
            duration: Duration::from_millis(1),
            issues: Vec::new(),
            recommendations: vec!["Ensure error messages are clear and actionable".to_string()],
        })
    }

    /// Test dimension mismatch errors
    fn test_dimension_mismatch_errors(&self) -> InterpolateResult<StressTestResult> {
        let (x, y) = create_mismatched_data()?;
        let x_query = Array1::from_vec(vec![T::from_f64(1.0).expect("Operation failed")]);

        let result = crate::interp1d::linear_interpolate(&x.view(), &y.view(), &x_query.view());

        let status = match result {
            Err(e) => {
                let error_msg = e.to_string();
                if error_msg.contains("length") || error_msg.contains("dimension") {
                    TestStatus::Passed
                } else {
                    TestStatus::PassedWithWarnings
                }
            }
            Ok(_) => TestStatus::Failed,
        };

        Ok(StressTestResult {
            test_name: "dimension_mismatch_error_clarity".to_string(),
            category: StressTestCategory::ErrorHandling,
            input_characteristics: "Mismatched array dimensions".to_string(),
            status,
            execution_time: Duration::from_millis(1),
            performance: StressPerformanceMetrics::default(),
            error_info: None,
            memory_usage: MemoryUsageStats::default(),
            duration: Duration::from_millis(1),
            issues: Vec::new(),
            recommendations: vec![
                "Provide specific dimension information in error messages".to_string()
            ],
        })
    }

    /// Test parameter validation errors
    fn test_parameter_validation_errors(&self) -> InterpolateResult<StressTestResult> {
        // This would test parameter validation, but our current API doesn't have many parameters
        // to validate. This is a placeholder for future parameter validation tests.

        Ok(StressTestResult {
            test_name: "parameter_validation_error_clarity".to_string(),
            category: StressTestCategory::ErrorHandling,
            input_characteristics: "Invalid parameters".to_string(),
            status: TestStatus::Skipped,
            execution_time: Duration::from_millis(1),
            performance: StressPerformanceMetrics::default(),
            error_info: None,
            memory_usage: MemoryUsageStats::default(),
            duration: Duration::from_millis(1),
            issues: Vec::new(),
            recommendations: vec!["Add parameter validation as API expands".to_string()],
        })
    }

    /// Test numerical error messages
    fn test_numerical_error_messages(&self) -> InterpolateResult<StressTestResult> {
        let (x, y) = create_nan_inf_data(100)?;
        let x_query = Array1::linspace(
            T::from_f64(1.0).expect("Operation failed"),
            T::from_f64(9.0).expect("Operation failed"),
            10,
        );

        let result = crate::interp1d::linear_interpolate(&x.view(), &y.view(), &x_query.view());

        let status = match result {
            Err(e) => {
                let error_msg = e.to_string();
                if error_msg.contains("NaN")
                    || error_msg.contains("infinite")
                    || error_msg.contains("numerical")
                {
                    TestStatus::Passed
                } else {
                    TestStatus::PassedWithWarnings
                }
            }
            Ok(_) => TestStatus::PassedWithWarnings, // Should probably detect NaN/inf
        };

        Ok(StressTestResult {
            test_name: "numerical_error_clarity".to_string(),
            category: StressTestCategory::ErrorHandling,
            input_characteristics: "Data with NaN/infinite values".to_string(),
            status,
            execution_time: Duration::from_millis(1),
            performance: StressPerformanceMetrics::default(),
            error_info: None,
            memory_usage: MemoryUsageStats::default(),
            duration: Duration::from_millis(1),
            issues: Vec::new(),
            recommendations: vec!["Improve detection and reporting of numerical issues".to_string()],
        })
    }

    /// Test resource exhaustion recovery
    pub fn test_resource_exhaustion_recovery(&mut self) -> InterpolateResult<()> {
        println!("Testing resource exhaustion recovery...");

        // Test memory exhaustion scenarios
        let large_sizes = [500_000, 1_000_000];

        for (i, &size) in large_sizes.iter().enumerate() {
            let test_result = match std::panic::catch_unwind(|| create_large_test_data(size)) {
                Ok(Ok((x, y))) => {
                    let start = Instant::now();

                    // Try to process the large dataset
                    let x_query = Array1::linspace(
                        T::from_f64(1.0).expect("Operation failed"),
                        T::from_f64(9.0).expect("Operation failed"),
                        1000,
                    );

                    match crate::interp1d::linear_interpolate(&x.view(), &y.view(), &x_query.view())
                    {
                        Ok(_) => self.create_success_result(
                            &format!("resource_exhaustion_{}", i),
                            size,
                            start.elapsed(),
                            StressTestCategory::ResourceExhaustion,
                        ),
                        Err(e) => self.create_error_result(
                            &format!("resource_exhaustion_{}", i),
                            size,
                            e,
                            StressTestCategory::ResourceExhaustion,
                        ),
                    }
                }
                Ok(Err(e)) => self.create_error_result(
                    &format!("resource_exhaustion_{}", i),
                    size,
                    e,
                    StressTestCategory::ResourceExhaustion,
                ),
                Err(_) => self.create_panic_result(
                    &format!("resource_exhaustion_{}", i),
                    size,
                    StressTestCategory::ResourceExhaustion,
                ),
            };

            self.results.push(test_result);
        }

        Ok(())
    }
}