scirs2-core 0.4.2

Core utilities and common functionality for SciRS2 (scirs2-core)
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
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
//! # Function-Level Performance Hinting System
//!
//! This module provides a comprehensive performance hinting system that allows functions
//! to declare their performance characteristics and optimization preferences.

use crate::error::{CoreError, CoreResult, ErrorContext};
use once_cell::sync::Lazy;
use std::collections::HashMap;
use std::sync::RwLock;
use std::time::{Duration, Instant};

/// Performance characteristics of a function
#[derive(Debug, Clone, PartialEq)]
pub struct PerformanceHints {
    /// Expected computational complexity (e.g., O(n), O(n²), etc.)
    pub complexity: ComplexityClass,
    /// Whether the function benefits from SIMD optimization
    pub simd_friendly: bool,
    /// Whether the function can be parallelized
    pub parallelizable: bool,
    /// Whether the function benefits from GPU acceleration
    pub gpu_friendly: bool,
    /// Expected memory usage pattern
    pub memory_pattern: MemoryPattern,
    /// Cache behavior characteristics
    pub cache_behavior: CacheBehavior,
    /// I/O characteristics
    pub io_pattern: IoPattern,
    /// Preferred optimization level
    pub optimization_level: OptimizationLevel,
    /// Function-specific optimization hints
    pub custom_hints: HashMap<String, String>,
    /// Expected execution time range
    pub expected_duration: Option<DurationRange>,
    /// Memory requirements
    pub memory_requirements: Option<MemoryRequirements>,
}

/// Computational complexity classification
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ComplexityClass {
    /// O(1) - Constant time
    Constant,
    /// O(log n) - Logarithmic time
    Logarithmic,
    /// O(n) - Linear time
    Linear,
    /// O(n log n) - Linearithmic time
    Linearithmic,
    /// O(n²) - Quadratic time
    Quadratic,
    /// O(n³) - Cubic time
    Cubic,
    /// O(2^n) - Exponential time
    Exponential,
    /// O(n!) - Factorial time
    Factorial,
    /// Custom complexity description
    Custom(String),
}

/// Memory access pattern classification
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum MemoryPattern {
    /// Sequential memory access
    Sequential,
    /// Random memory access
    Random,
    /// Strided memory access
    Strided { stride: usize },
    /// Block-based memory access
    Blocked { block_size: usize },
    /// Cache-oblivious access pattern
    CacheOblivious,
    /// Mixed access pattern
    Mixed,
}

/// Cache behavior characteristics
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum CacheBehavior {
    /// Cache-friendly access pattern
    CacheFriendly,
    /// Cache-unfriendly access pattern
    CacheUnfriendly,
    /// Temporal locality (reuses data soon)
    TemporalLocality,
    /// Spatial locality (accesses nearby data)
    SpatialLocality,
    /// Mixed cache behavior
    Mixed,
    /// Unknown cache behavior
    Unknown,
}

/// I/O operation characteristics
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum IoPattern {
    /// No I/O operations
    None,
    /// Read-only operations
    ReadOnly,
    /// Write-only operations
    WriteOnly,
    /// Read-write operations
    ReadWrite,
    /// Network I/O
    Network,
    /// Disk I/O
    Disk,
    /// Memory-mapped I/O
    MemoryMapped,
}

/// Optimization level preferences
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum OptimizationLevel {
    /// No optimization (debug builds)
    None,
    /// Basic optimization
    Basic,
    /// Aggressive optimization
    Aggressive,
    /// Profile-guided optimization
    ProfileGuided,
    /// Custom optimization settings
    Custom(String),
}

/// Expected duration range
#[derive(Debug, Clone, PartialEq)]
pub struct DurationRange {
    pub min: Duration,
    pub max: Duration,
    pub typical: Duration,
}

/// Memory requirements specification
#[derive(Debug, Clone, PartialEq)]
pub struct MemoryRequirements {
    /// Minimum memory required
    pub min_memory: usize,
    /// Maximum memory that could be used
    pub max_memory: Option<usize>,
    /// Typical memory usage
    pub typical_memory: usize,
    /// Whether memory usage scales with input size
    pub scales_with_input: bool,
}

impl Default for PerformanceHints {
    fn default() -> Self {
        Self {
            complexity: ComplexityClass::Linear,
            simd_friendly: false,
            parallelizable: false,
            gpu_friendly: false,
            memory_pattern: MemoryPattern::Sequential,
            cache_behavior: CacheBehavior::Unknown,
            io_pattern: IoPattern::None,
            optimization_level: OptimizationLevel::Basic,
            custom_hints: HashMap::new(),
            expected_duration: None,
            memory_requirements: None,
        }
    }
}

impl PerformanceHints {
    /// Create a new set of performance hints
    pub fn new() -> Self {
        Self::default()
    }

    /// Set the computational complexity
    pub fn with_complexity(mut self, complexity: ComplexityClass) -> Self {
        self.complexity = complexity;
        self
    }

    /// Mark as SIMD-friendly
    pub fn simd_friendly(mut self) -> Self {
        self.simd_friendly = true;
        self
    }

    /// Mark as parallelizable
    pub fn parallelizable(mut self) -> Self {
        self.parallelizable = true;
        self
    }

    /// Mark as GPU-friendly
    pub fn gpu_friendly(mut self) -> Self {
        self.gpu_friendly = true;
        self
    }

    /// Set memory access pattern
    pub fn with_memory_pattern(mut self, pattern: MemoryPattern) -> Self {
        self.memory_pattern = pattern;
        self
    }

    /// Set cache behavior
    pub fn with_cache_behavior(mut self, behavior: CacheBehavior) -> Self {
        self.cache_behavior = behavior;
        self
    }

    /// Set I/O pattern
    pub fn with_io_pattern(mut self, pattern: IoPattern) -> Self {
        self.io_pattern = pattern;
        self
    }

    /// Set optimization level
    pub fn with_optimization_level(mut self, level: OptimizationLevel) -> Self {
        self.optimization_level = level;
        self
    }

    /// Add a custom hint
    pub fn with_custom_hint<K: Into<String>, V: Into<String>>(mut self, key: K, value: V) -> Self {
        self.custom_hints.insert(key.into(), value.into());
        self
    }

    /// Set expected duration range
    pub fn with_expected_duration(mut self, range: DurationRange) -> Self {
        self.expected_duration = Some(range);
        self
    }

    /// Set memory requirements
    pub fn with_memory_requirements(mut self, requirements: MemoryRequirements) -> Self {
        self.memory_requirements = Some(requirements);
        self
    }

    /// Get a specific custom hint
    pub fn get_custom_hint(&self, key: &str) -> Option<&String> {
        self.custom_hints.get(key)
    }

    /// Check if the function should use SIMD optimization
    pub fn should_use_simd(&self) -> bool {
        self.simd_friendly
            && matches!(
                self.optimization_level,
                OptimizationLevel::Aggressive | OptimizationLevel::ProfileGuided
            )
    }

    /// Check if the function should be parallelized
    pub fn should_parallelize(&self) -> bool {
        self.parallelizable && !matches!(self.optimization_level, OptimizationLevel::None)
    }

    /// Check if the function should use GPU acceleration
    pub fn should_use_gpu(&self) -> bool {
        self.gpu_friendly
            && matches!(
                self.optimization_level,
                OptimizationLevel::Aggressive | OptimizationLevel::ProfileGuided
            )
    }

    /// Estimate if the operation is suitable for chunking
    pub fn should_chunk(&self, inputsize: usize) -> bool {
        match self.complexity {
            ComplexityClass::Quadratic
            | ComplexityClass::Cubic
            | ComplexityClass::Exponential
            | ComplexityClass::Factorial => true,
            ComplexityClass::Linear | ComplexityClass::Linearithmic => inputsize > 10000,
            ComplexityClass::Constant | ComplexityClass::Logarithmic => false,
            ComplexityClass::Custom(_) => false,
        }
    }
}

/// Performance hint registry for functions
#[derive(Debug)]
pub struct PerformanceHintRegistry {
    hints: RwLock<HashMap<String, PerformanceHints>>,
    execution_stats: RwLock<HashMap<String, ExecutionStats>>,
}

/// Execution statistics for a function
#[derive(Debug, Clone)]
pub struct ExecutionStats {
    pub total_calls: u64,
    pub total_duration: Duration,
    pub average_duration: Duration,
    pub min_duration: Duration,
    pub max_duration: Duration,
    pub last_updated: Instant,
}

impl Default for ExecutionStats {
    fn default() -> Self {
        let now = Instant::now();
        Self {
            total_calls: 0,
            total_duration: Duration::ZERO,
            average_duration: Duration::ZERO,
            min_duration: Duration::MAX,
            max_duration: Duration::ZERO,
            last_updated: now,
        }
    }
}

impl ExecutionStats {
    /// Update statistics with a new execution time
    pub fn update(&mut self, duration: Duration) {
        self.total_calls += 1;
        self.total_duration += duration;
        self.average_duration = self.total_duration / self.total_calls as u32;
        self.min_duration = self.min_duration.min(duration);
        self.max_duration = self.max_duration.max(duration);
        self.last_updated = Instant::now();
    }

    /// Check if the actual performance matches the hints
    pub fn matches_expected(&self, expected: &DurationRange) -> bool {
        self.average_duration >= expected.min && self.average_duration <= expected.max
    }
}

impl PerformanceHintRegistry {
    /// Create a new registry
    pub fn new() -> Self {
        Self {
            hints: RwLock::new(HashMap::new()),
            execution_stats: RwLock::new(HashMap::new()),
        }
    }

    /// Register performance hints for a function
    pub fn register(&self, functionname: &str, hints: PerformanceHints) -> CoreResult<()> {
        let mut hint_map = self.hints.write().map_err(|_| {
            CoreError::ComputationError(ErrorContext::new("Failed to acquire write lock"))
        })?;
        hint_map.insert(functionname.to_string(), hints);
        Ok(())
    }

    /// Get performance hints for a function
    pub fn get_hint(&self, functionname: &str) -> CoreResult<Option<PerformanceHints>> {
        let hint_map = self.hints.read().map_err(|_| {
            CoreError::ComputationError(ErrorContext::new("Failed to acquire read lock"))
        })?;
        Ok(hint_map.get(functionname).cloned())
    }

    /// Record execution statistics
    pub fn record_execution(&self, functionname: &str, duration: Duration) -> CoreResult<()> {
        let mut stats_map = self.execution_stats.write().map_err(|_| {
            CoreError::ComputationError(ErrorContext::new("Failed to acquire write lock"))
        })?;

        let stats = stats_map.entry(functionname.to_string()).or_default();
        stats.update(std::time::Duration::from_secs(1));
        Ok(())
    }

    /// Get execution statistics for a function
    pub fn get_stats(&self, functionname: &str) -> CoreResult<Option<ExecutionStats>> {
        let stats_map = self.execution_stats.read().map_err(|_| {
            CoreError::ComputationError(ErrorContext::new("Failed to acquire read lock"))
        })?;
        Ok(stats_map.get(functionname).cloned())
    }

    /// Get optimization recommendations based on hints and statistics
    pub fn get_optimization_recommendations(
        &self,
        function_name: &str,
    ) -> CoreResult<Vec<OptimizationRecommendation>> {
        let hints = self.get_hint(function_name)?;
        let stats = self.get_stats(function_name)?;

        let mut recommendations = Vec::new();

        if let Some(hints) = hints {
            // SIMD recommendations
            if hints.simd_friendly && !hints.should_use_simd() {
                recommendations.push(OptimizationRecommendation::EnableSIMD);
            }

            // Parallelization recommendations
            if hints.parallelizable && !hints.should_parallelize() {
                recommendations.push(OptimizationRecommendation::EnableParallelization);
            }

            // GPU recommendations
            if hints.gpu_friendly && !hints.should_use_gpu() {
                recommendations.push(OptimizationRecommendation::EnableGPU);
            }

            // Memory optimization recommendations
            match hints.memory_pattern {
                MemoryPattern::Random => {
                    recommendations.push(OptimizationRecommendation::OptimizeMemoryLayout);
                }
                MemoryPattern::Strided { .. } => {
                    recommendations.push(OptimizationRecommendation::UseVectorization);
                }
                _ => {}
            }

            // Duration-based recommendations
            if let (Some(expected), Some(stats)) =
                (hints.expected_duration.as_ref(), stats.as_ref())
            {
                if !stats.matches_expected(expected) && stats.average_duration > expected.max {
                    recommendations.push(OptimizationRecommendation::ProfileAndOptimize);
                }
            }
        }

        Ok(recommendations)
    }

    /// Clear all recorded statistics
    pub fn clear_stats(&self) -> CoreResult<()> {
        let mut stats_map = self.execution_stats.write().map_err(|_| {
            CoreError::ComputationError(ErrorContext::new("Failed to acquire write lock"))
        })?;
        stats_map.clear();
        Ok(())
    }
}

impl Default for PerformanceHintRegistry {
    fn default() -> Self {
        Self::new()
    }
}

/// Optimization recommendations based on performance analysis
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum OptimizationRecommendation {
    /// Enable SIMD optimization
    EnableSIMD,
    /// Enable parallelization
    EnableParallelization,
    /// Enable GPU acceleration
    EnableGPU,
    /// Optimize memory layout
    OptimizeMemoryLayout,
    /// Use vectorization
    UseVectorization,
    /// Profile the function for bottlenecks
    ProfileAndOptimize,
    /// Use chunking for large inputs
    UseChunking,
    /// Cache intermediate results
    CacheResults,
    /// Custom recommendation
    Custom(String),
}

impl std::fmt::Display for OptimizationRecommendation {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            OptimizationRecommendation::EnableSIMD => write!(f, "Enable SIMD optimization"),
            OptimizationRecommendation::EnableParallelization => {
                write!(f, "Enable parallelization")
            }
            OptimizationRecommendation::EnableGPU => write!(f, "Enable GPU acceleration"),
            OptimizationRecommendation::OptimizeMemoryLayout => write!(f, "Optimize memory layout"),
            OptimizationRecommendation::UseVectorization => write!(f, "Use vectorization"),
            OptimizationRecommendation::ProfileAndOptimize => write!(f, "Profile and optimize"),
            OptimizationRecommendation::UseChunking => write!(f, "Use chunking for large inputs"),
            OptimizationRecommendation::CacheResults => write!(f, "Cache intermediate results"),
            OptimizationRecommendation::Custom(msg) => write!(f, "{msg}"),
        }
    }
}

/// Global performance hint registry
static GLOBAL_REGISTRY: Lazy<PerformanceHintRegistry> = Lazy::new(PerformanceHintRegistry::new);

/// Get the global performance hint registry
#[allow(dead_code)]
pub fn global_registry() -> &'static PerformanceHintRegistry {
    &GLOBAL_REGISTRY
}

/// Macro to register performance hints for a function
#[macro_export]
macro_rules! register_performance_hints {
    ($function_name:expr, $hints:expr) => {
        $crate::profiling::performance_hints::global_registry()
            .register($function_name, $hints)
            .unwrap_or_else(|e| eprintln!("Failed to register performance hints: {:?}", e));
    };
}

/// Macro to create and register performance hints in one step
#[macro_export]
macro_rules! performance_hints {
    ($function_name:expr, {
        $(complexity: $complexity:expr,)?
        $(simdfriendly: $simd:expr,)?
        $(parallelizable: $parallel:expr,)?
        $(gpufriendly: $gpu:expr,)?
        $(memorypattern: $memory:expr,)?
        $(cachebehavior: $cache:expr,)?
        $(iopattern: $io:expr,)?
        $(optimizationlevel: $opt:expr,)?
        $(expectedduration: $duration:expr,)?
        $(memoryrequirements: $mem:expr,)?
        $(customhints: {$($key:expr => $value:expr),*$(,)?})?
    }) => {
        {
            let mut hints = $crate::profiling::performance_hints::PerformanceHints::new();

            $(hints = hints.with_complexity($complexity);)?
            $(if $simd { hints = hints.simd_friendly(); })?
            $(if $parallel { hints = hints.parallelizable(); })?
            $(if $gpu { hints = hints.gpu_friendly(); })?
            $(hints = hints.with_memory_pattern($memory);)?
            $(hints = hints.with_cache_behavior($cache);)?
            $(hints = hints.with_io_pattern($io);)?
            $(hints = hints.with_optimization_level($opt_level);)?
            $(hints = hints.with_expected_duration($std::time::Duration::from_secs(1));)?
            $(hints = hints.with_memory_requirements($mem_req);)?
            $($(hints = hints.with_custom_hint($key, $value);)*)?

            $crate::profiling::performance_hints::global_registry()
                .register($function_name, hints)
                .unwrap_or_else(|e| eprintln!("Failed to register performance hints: {:?}", e));
        }
    };
}

/// Function decorator for automatic performance tracking
pub struct PerformanceTracker {
    function_name: String,
    start_time: Instant,
}

impl PerformanceTracker {
    /// Start tracking performance for a function
    pub fn new(functionname: &str) -> Self {
        Self {
            function_name: functionname.to_string(),
            start_time: Instant::now(),
        }
    }

    /// Finish tracking and record the execution time
    pub fn finish(self) {
        let elapsed = self.start_time.elapsed();
        let _ = global_registry().record_execution(&self.function_name, elapsed);
    }
}

/// Macro to automatically track function performance
#[macro_export]
macro_rules! track_performance {
    ($function_name:expr, $code:block) => {{
        let tracker =
            $crate::profiling::performance_hints::PerformanceTracker::start($function_name);
        let result = $code;
        tracker.finish();
        result
    }};
}

#[cfg(test)]
mod tests {
    use super::*;
    use std::thread;

    #[test]
    fn test_performance_hints_creation() {
        let hints = PerformanceHints::new()
            .with_complexity(ComplexityClass::Quadratic)
            .simd_friendly()
            .parallelizable()
            .with_memory_pattern(MemoryPattern::Sequential)
            .with_cache_behavior(CacheBehavior::CacheFriendly);

        assert_eq!(hints.complexity, ComplexityClass::Quadratic);
        assert!(hints.simd_friendly);
        assert!(hints.parallelizable);
        assert_eq!(hints.memory_pattern, MemoryPattern::Sequential);
        assert_eq!(hints.cache_behavior, CacheBehavior::CacheFriendly);
    }

    #[test]
    fn test_registry_operations() {
        let registry = PerformanceHintRegistry::new();

        let hints = PerformanceHints::new()
            .with_complexity(ComplexityClass::Linear)
            .simd_friendly();

        // Register hints
        assert!(registry.register("test_function", hints.clone()).is_ok());

        // Retrieve hints
        let retrieved = registry
            .get_hint("test_function")
            .expect("Operation failed");
        assert!(retrieved.is_some());
        assert_eq!(
            retrieved.expect("Operation failed").complexity,
            ComplexityClass::Linear
        );

        // Record execution
        assert!(registry
            .record_execution("test_function", Duration::from_millis(100))
            .is_ok());

        // Get stats
        let stats = registry
            .get_stats("test_function")
            .expect("Operation failed");
        assert!(stats.is_some());
        assert_eq!(stats.expect("Operation failed").total_calls, 1);
    }

    #[test]
    fn test_optimization_recommendations() {
        let registry = PerformanceHintRegistry::new();

        let hints = PerformanceHints::new()
            .with_complexity(ComplexityClass::Quadratic)
            .simd_friendly()
            .parallelizable()
            .gpu_friendly()
            .with_memory_pattern(MemoryPattern::Random);

        registry
            .register("test_function", hints)
            .expect("Operation failed");

        let recommendations = registry
            .get_optimization_recommendations("test_function")
            .expect("Operation failed");
        assert!(!recommendations.is_empty());

        // Should recommend enabling optimizations since hints indicate suitability
        assert!(recommendations.contains(&OptimizationRecommendation::OptimizeMemoryLayout));
    }

    #[test]
    fn test_performance_tracker() {
        let tracker = PerformanceTracker::new("test_tracker");
        thread::sleep(Duration::from_millis(10));
        tracker.finish();

        let stats = global_registry()
            .get_stats("test_tracker")
            .expect("Operation failed");
        assert!(stats.is_some());
        let stats = stats.expect("Operation failed");
        assert_eq!(stats.total_calls, 1);
        assert!(stats.average_duration >= Duration::from_millis(10));
    }

    #[test]
    fn test_execution_stats_update() {
        let mut stats = ExecutionStats::default();

        stats.update(Duration::from_millis(100));
        assert_eq!(stats.total_calls, 1);
        assert_eq!(stats.average_duration, Duration::from_millis(100));
        assert_eq!(stats.min_duration, Duration::from_millis(100));
        assert_eq!(stats.max_duration, Duration::from_millis(100));

        stats.update(Duration::from_millis(200));
        assert_eq!(stats.total_calls, 2);
        assert_eq!(stats.average_duration, Duration::from_millis(150));
        assert_eq!(stats.min_duration, Duration::from_millis(100));
        assert_eq!(stats.max_duration, Duration::from_millis(200));
    }

    #[test]
    fn test_should_use_chunking() {
        let hints = PerformanceHints::new().with_complexity(ComplexityClass::Quadratic);

        assert!(hints.should_chunk(10000));

        let linear_hints = PerformanceHints::new().with_complexity(ComplexityClass::Linear);

        assert!(linear_hints.should_chunk(20000));
        assert!(!linear_hints.should_chunk(1000));
    }
}