lambdust 0.1.1

A Scheme dialect with gradual typing and effect systems
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
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
//! Comprehensive Performance Comparison System for Lambdust
//!
//! This module implements a scientifically rigorous benchmark suite for comparing
//! Lambdust performance against major Scheme implementations. It provides:
//!
//! - Standardized cross-implementation benchmarks
//! - Statistical analysis with confidence intervals
//! - Performance regression detection
//! - Actionable optimization recommendations
//! - Automated result collection and reporting

use std::collections::HashMap;
use std::fs;
use std::process::Command;
use std::sync::{Arc, Mutex};
use std::thread;
use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
use serde::{Deserialize, Serialize};
use rayon::prelude::*;
use super::external_integration::{ExternalReporting, GitHubConfig, DashboardConfig, NotificationConfig};
use super::benchmark_config::{
    BenchmarkSuiteConfig, ImplementationConfig, RuntimeConfig, TestCategory, TestCase,
    TestParameter, ParameterValue, ScalingBehavior, ResultType, TestResourceLimits,
    PerformanceHints, StatisticalConfig, OutlierDetection, OutputConfig, OutputFormat,
    ChartType, ResourceConfig, SystemResourceLimits,
};
use super::system_metadata::{
    BenchmarkMetadata, SystemInfo, TestFailure, FailureReason, ResourceStats,
    CPUStats, MemoryStats, DiskIOStats, NetworkIOStats, BenchmarkResult,
};
use super::results_measurements::{
    ImplementationResult, CategoryResult, TestResult, TimingMeasurements,
    MemoryMeasurements, ConfidenceInterval as TimingConfidenceInterval, 
    ValidationResult, CategoryStatistics,
};
use super::statistical_analysis_results::{
    ImplementationComparison, StatisticalSignificance, CategoryComparison,
    StatisticalSummary, PerformanceRanking, DistributionStats, DistributionShape,
    CorrelationAnalysis,
};
use super::regression_optimization::{
    RegressionAnalysis, PerformanceRegression, PerformanceImprovement,
    RegressionSeverity, TrendAnalysis, TrendDirection, PerformanceForecast,
    OptimizationRecommendation,
};
use super::execution_management::{
    SystemResourceUsage, ResourceSnapshot, ResourceEfficiency,
};







/// Complete results from a full benchmark suite execution.
/// 
/// Contains all performance data, statistical analysis, and metadata
/// from comparing multiple implementations across test categories.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BenchmarkSuiteResult {
    /// Metadata about the benchmark run
    pub metadata: BenchmarkMetadata,
    /// Results by implementation and test
    pub implementation_results: HashMap<String, ImplementationResult>,
    /// Cross-implementation comparisons
    pub comparisons: Vec<ImplementationComparison>,
    /// Statistical analysis summary
    pub statistical_summary: StatisticalSummary,
    /// Performance regression analysis
    pub regression_analysis: Option<RegressionAnalysis>,
    /// Optimization recommendations
    pub recommendations: Vec<OptimizationRecommendation>,
    /// System resource usage during benchmarking
    pub resource_usage: SystemResourceUsage,
}








impl Default for BenchmarkSuiteConfig {
    fn default() -> Self {
        Self {
            implementations: Self::default_implementations(),
            test_categories: Self::default_test_categories(),
            statistical_config: StatisticalConfig::default(),
            output_config: OutputConfig::default(),
            resource_config: ResourceConfig::default(),
        }
    }
}

impl BenchmarkSuiteConfig {
    /// Default implementation configurations
    fn default_implementations() -> Vec<ImplementationConfig> {
        vec![
            ImplementationConfig {
                name: "Lambdust".to_string(),
                id: "lambdust".to_string(),
                runtime: RuntimeConfig::Lambdust {
                    target_dir: "./target".to_string(),
                    profile: "release".to_string(),
                    features: vec![],
                },
                version: env!("CARGO_PKG_VERSION").to_string(),
                expected_baseline: Some(5_000_000.0), // 5M ops/sec
                limitations: vec![],
                r7rs_compliant: true,
            },
            ImplementationConfig {
                name: "Chez Scheme".to_string(),
                id: "chez".to_string(),
                runtime: RuntimeConfig::Native {
                    binary_path: "scheme".to_string(),
                    args: vec!["--quiet".to_string(), "--script".to_string()],
                    env_vars: HashMap::new(),
                },
                version: "9.5+".to_string(),
                expected_baseline: Some(8_000_000.0), // High performance baseline
                limitations: vec![],
                r7rs_compliant: true,
            },
            ImplementationConfig {
                name: "Racket".to_string(),
                id: "racket".to_string(),
                runtime: RuntimeConfig::Native {
                    binary_path: "racket".to_string(),
                    args: vec!["-t".to_string()],
                    env_vars: HashMap::new(),
                },
                version: "8.11+".to_string(),
                expected_baseline: Some(3_000_000.0),
                limitations: vec!["Different numeric tower".to_string()],
                r7rs_compliant: true,
            },
            // Additional implementations would be defined here...
        ]
    }
    
    /// Default test categories
    fn default_test_categories() -> Vec<TestCategory> {
        vec![
            TestCategory {
                name: "arithmetic".to_string(),
                description: "Arithmetic operations and numeric tower".to_string(),
                tests: Self::arithmetic_tests(),
                weight: 0.25,
                critical: true,
            },
            TestCategory {
                name: "lists".to_string(),
                description: "List operations and data structure manipulation".to_string(),
                tests: Self::list_tests(),
                weight: 0.20,
                critical: true,
            },
            TestCategory {
                name: "recursion".to_string(),
                description: "Recursive algorithms and tail call optimization".to_string(),
                tests: Self::recursion_tests(),
                weight: 0.15,
                critical: true,
            },
            TestCategory {
                name: "memory".to_string(),
                description: "Memory allocation and garbage collection".to_string(),
                tests: Self::memory_tests(),
                weight: 0.15,
                critical: false,
            },
            TestCategory {
                name: "io".to_string(),
                description: "Input/output operations".to_string(),
                tests: Self::io_tests(),
                weight: 0.10,
                critical: false,
            },
            TestCategory {
                name: "macros".to_string(),
                description: "Macro expansion and metaprogramming".to_string(),
                tests: Self::macro_tests(),
                weight: 0.10,
                critical: false,
            },
            TestCategory {
                name: "strings".to_string(),
                description: "String manipulation and processing".to_string(),
                tests: Self::string_tests(),
                weight: 0.05,
                critical: false,
            },
        ]
    }
    
    /// Arithmetic test cases
    fn arithmetic_tests() -> Vec<TestCase> {
        vec![
            TestCase {
                name: "integer_arithmetic".to_string(),
                description: "Basic integer arithmetic operations".to_string(),
                code_template: r#"
                    (define (arithmetic-benchmark n)
                      (let loop ((i 0) (sum 0))
                        (if (< i n)
                            (loop (+ i 1) (+ sum (* i i)))
                            sum)))
                    (time (arithmetic-benchmark {n}))
                "#.to_string(),
                parameters: vec![
                    TestParameter {
                        name: "n".to_string(),
                        values: vec![
                            ParameterValue::Range { start: 1000, end: 100000, step: 10000 },
                        ],
                        scaling_behavior: ScalingBehavior::Linear,
                    }
                ],
                expected_result_type: ResultType::Number,
                resource_limits: TestResourceLimits {
                    max_time_seconds: 30,
                    max_memory_mb: 100,
                    max_cpu_percent: 100.0,
                },
                performance_hints: PerformanceHints {
                    fast_path_candidates: vec!["+".to_string(), "*".to_string()],
                    memory_patterns: vec!["constant memory".to_string()],
                    complexity: ScalingBehavior::Linear,
                    critical_operations: vec!["arithmetic".to_string()],
                },
            },
            // Additional arithmetic tests...
        ]
    }
    
    /// List operation test cases
    fn list_tests() -> Vec<TestCase> {
        vec![
            TestCase {
                name: "list_creation".to_string(),
                description: "List creation and basic operations".to_string(),
                code_template: r#"
                    (define (list-benchmark n)
                      (let loop ((i 0) (lst '()))
                        (if (< i n)
                            (loop (+ i 1) (cons i lst))
                            (length lst))))
                    (time (list-benchmark {n}))
                "#.to_string(),
                parameters: vec![
                    TestParameter {
                        name: "n".to_string(),
                        values: vec![
                            ParameterValue::Range { start: 1000, end: 50000, step: 5000 },
                        ],
                        scaling_behavior: ScalingBehavior::Linear,
                    }
                ],
                expected_result_type: ResultType::Number,
                resource_limits: TestResourceLimits {
                    max_time_seconds: 60,
                    max_memory_mb: 200,
                    max_cpu_percent: 100.0,
                },
                performance_hints: PerformanceHints {
                    fast_path_candidates: vec!["cons".to_string(), "length".to_string()],
                    memory_patterns: vec!["linear allocation".to_string()],
                    complexity: ScalingBehavior::Linear,
                    critical_operations: vec!["cons".to_string(), "list traversal".to_string()],
                },
            },
            // Additional list tests...
        ]
    }
    
    /// Recursion test cases
    fn recursion_tests() -> Vec<TestCase> {
        vec![
            TestCase {
                name: "fibonacci".to_string(),
                description: "Fibonacci sequence calculation".to_string(),
                code_template: r#"
                    (define (fib n)
                      (if (<= n 1)
                          n
                          (+ (fib (- n 1)) (fib (- n 2)))))
                    (time (fib {n}))
                "#.to_string(),
                parameters: vec![
                    TestParameter {
                        name: "n".to_string(),
                        values: vec![
                            ParameterValue::Range { start: 20, end: 35, step: 5 },
                        ],
                        scaling_behavior: ScalingBehavior::Exponential,
                    }
                ],
                expected_result_type: ResultType::Number,
                resource_limits: TestResourceLimits {
                    max_time_seconds: 120,
                    max_memory_mb: 500,
                    max_cpu_percent: 100.0,
                },
                performance_hints: PerformanceHints {
                    fast_path_candidates: vec!["+".to_string(), "-".to_string()],
                    memory_patterns: vec!["exponential stack growth".to_string()],
                    complexity: ScalingBehavior::Exponential,
                    critical_operations: vec!["recursion".to_string(), "function calls".to_string()],
                },
            },
            // Additional recursion tests...
        ]
    }
    
    /// Memory management test cases  
    fn memory_tests() -> Vec<TestCase> {
        vec![
            TestCase {
                name: "allocation_stress".to_string(),
                description: "Memory allocation and garbage collection stress test".to_string(),
                code_template: r#"
                    (define (allocation-benchmark n)
                      (let loop ((i 0) (acc '()))
                        (if (< i n)
                            (let ((big-list (make-list 1000 i)))
                              (loop (+ i 1) (cons big-list acc)))
                            (length acc))))
                    (time (allocation-benchmark {n}))
                "#.to_string(),
                parameters: vec![
                    TestParameter {
                        name: "n".to_string(),
                        values: vec![
                            ParameterValue::Range { start: 100, end: 1000, step: 100 },
                        ],
                        scaling_behavior: ScalingBehavior::Linear,
                    }
                ],
                expected_result_type: ResultType::Number,
                resource_limits: TestResourceLimits {
                    max_time_seconds: 180,
                    max_memory_mb: 1000,
                    max_cpu_percent: 100.0,
                },
                performance_hints: PerformanceHints {
                    fast_path_candidates: vec![],
                    memory_patterns: vec!["high allocation rate".to_string(), "GC pressure".to_string()],
                    complexity: ScalingBehavior::Linear,
                    critical_operations: vec!["allocation".to_string(), "GC".to_string()],
                },
            },
            // Additional memory tests...
        ]
    }
    
    /// I/O operation test cases
    fn io_tests() -> Vec<TestCase> {
        vec![
            TestCase {
                name: "string_port_operations".to_string(),
                description: "String port I/O operations".to_string(),
                code_template: r#"
                    (define (io-benchmark n)
                      (let ((output-port (open-output-string)))
                        (let loop ((i 0))
                          (if (< i n)
                              (begin
                                (write i output-port)
                                (newline output-port)
                                (loop (+ i 1)))
                              (string-length (get-output-string output-port))))))
                    (time (io-benchmark {n}))
                "#.to_string(),
                parameters: vec![
                    TestParameter {
                        name: "n".to_string(),
                        values: vec![
                            ParameterValue::Range { start: 1000, end: 10000, step: 1000 },
                        ],
                        scaling_behavior: ScalingBehavior::Linear,
                    }
                ],
                expected_result_type: ResultType::Number,
                resource_limits: TestResourceLimits {
                    max_time_seconds: 60,
                    max_memory_mb: 200,
                    max_cpu_percent: 100.0,
                },
                performance_hints: PerformanceHints {
                    fast_path_candidates: vec!["write".to_string()],
                    memory_patterns: vec!["string buffer growth".to_string()],
                    complexity: ScalingBehavior::Linear,
                    critical_operations: vec!["I/O".to_string(), "string operations".to_string()],
                },
            },
            // Additional I/O tests...
        ]
    }
    
    /// Macro expansion test cases
    fn macro_tests() -> Vec<TestCase> {
        vec![
            TestCase {
                name: "macro_expansion".to_string(),
                description: "Complex macro expansion performance".to_string(),
                code_template: r#"
                    (define-syntax repeat
                      (syntax-rules ()
                        ((repeat n expr)
                         (let loop ((i 0))
                           (if (< i n)
                               (begin expr (loop (+ i 1)))
                               'done)))))
                    
                    (define (macro-benchmark n)
                      (repeat n (+ 1 2 3)))
                    
                    (time (macro-benchmark {n}))
                "#.to_string(),
                parameters: vec![
                    TestParameter {
                        name: "n".to_string(),
                        values: vec![
                            ParameterValue::Range { start: 1000, end: 10000, step: 1000 },
                        ],
                        scaling_behavior: ScalingBehavior::Linear,
                    }
                ],
                expected_result_type: ResultType::Any,
                resource_limits: TestResourceLimits {
                    max_time_seconds: 60,
                    max_memory_mb: 100,
                    max_cpu_percent: 100.0,
                },
                performance_hints: PerformanceHints {
                    fast_path_candidates: vec![],
                    memory_patterns: vec!["macro expansion overhead".to_string()],
                    complexity: ScalingBehavior::Linear,
                    critical_operations: vec!["macro expansion".to_string()],
                },
            },
            // Additional macro tests...
        ]
    }
    
    /// String manipulation test cases
    fn string_tests() -> Vec<TestCase> {
        vec![
            TestCase {
                name: "string_concatenation".to_string(),
                description: "String concatenation performance".to_string(),
                code_template: r#"
                    (define (string-benchmark n)
                      (let loop ((i 0) (result ""))
                        (if (< i n)
                            (loop (+ i 1) (string-append result (number->string i) " "))
                            (string-length result))))
                    (time (string-benchmark {n}))
                "#.to_string(),
                parameters: vec![
                    TestParameter {
                        name: "n".to_string(),
                        values: vec![
                            ParameterValue::Range { start: 100, end: 1000, step: 100 },
                        ],
                        scaling_behavior: ScalingBehavior::Quadratic, // Due to repeated concatenation
                    }
                ],
                expected_result_type: ResultType::Number,
                resource_limits: TestResourceLimits {
                    max_time_seconds: 60,
                    max_memory_mb: 200,
                    max_cpu_percent: 100.0,
                },
                performance_hints: PerformanceHints {
                    fast_path_candidates: vec!["string-append".to_string()],
                    memory_patterns: vec!["quadratic memory growth".to_string()],
                    complexity: ScalingBehavior::Quadratic,
                    critical_operations: vec!["string operations".to_string()],
                },
            },
            // Additional string tests...
        ]
    }
}

impl Default for StatisticalConfig {
    fn default() -> Self {
        Self {
            iterations: 10,
            warmup_iterations: 3,
            confidence_level: 0.95,
            min_detectable_difference: 5.0,
            outlier_detection: OutlierDetection::IQR { multiplier: 1.5 },
            normality_tests: true,
        }
    }
}

impl Default for OutputConfig {
    fn default() -> Self {
        Self {
            output_dir: "./benchmark_results".to_string(),
            formats: vec![OutputFormat::JSON, OutputFormat::HTML, OutputFormat::CSV],
            generate_charts: true,
            chart_types: vec![
                ChartType::BarChart,
                ChartType::BoxPlot,
                ChartType::PerformanceProfile,
                ChartType::ImplementationComparison,
            ],
            external_reporting: None,
        }
    }
}

impl Default for ResourceConfig {
    fn default() -> Self {
        Self {
            monitor_cpu: true,
            monitor_memory: true,
            monitor_disk_io: true,
            monitor_network_io: false,
            sampling_interval_ms: 100,
            limits: SystemResourceLimits {
                max_total_memory_mb: 4096,
                max_cpu_percent: 95.0,
                max_disk_usage_mb: 1024,
                global_timeout_seconds: 3600, // 1 hour
            },
        }
    }
}

/// Main benchmark suite executor
pub struct ComprehensiveBenchmarkSuite {
    config: BenchmarkSuiteConfig,
    resource_monitor: Arc<Mutex<SystemResourceMonitor>>,
}

/// System resource monitoring
struct SystemResourceMonitor {
    monitoring: bool,
    samples: Vec<ResourceSnapshot>,
    start_time: SystemTime,
}

impl ComprehensiveBenchmarkSuite {
    /// Create a new benchmark suite with the given configuration
    pub fn new(config: BenchmarkSuiteConfig) -> Self {
        let resource_monitor = Arc::new(Mutex::new(SystemResourceMonitor {
            monitoring: false,
            samples: Vec::new(),
            start_time: SystemTime::now(),
        }));
        
        Self {
            config,
            resource_monitor,
        }
    }
    
    /// Execute the complete benchmark suite
    pub fn execute(&mut self) -> Result<BenchmarkSuiteResult, Box<dyn std::error::Error>> {
        println!("Starting comprehensive benchmark suite...");
        
        let start_time = SystemTime::now();
        
        // Start resource monitoring
        self.start_resource_monitoring();
        
        // Collect system information
        let system_info = self.collect_system_info();
        
        // Initialize results structure
        let mut implementation_results = HashMap::new();
        
        // Execute benchmarks for each implementation
        for impl_config in &self.config.implementations {
            println!("Benchmarking {}...", impl_config.name);
            
            match self.benchmark_implementation(impl_config) {
                Ok(result) => {
                    implementation_results.insert(impl_config.id.clone(), result);
                }
                Err(e) => {
                    eprintln!("Failed to benchmark {}: {}", impl_config.name, e);
                    // Create a failure result
                    let failure_result = ImplementationResult {
                        config: impl_config.clone(),
                        category_results: HashMap::new(),
                        overall_score: 0.0,
                        ranking: 0,
                        failures: vec![Box::new(TestFailure {
                            test_name: "suite_execution".to_string(),
                            category: "infrastructure".to_string(),
                            parameters: HashMap::new(),
                            reason: FailureReason::InfrastructureError,
                            error_message: e.to_string(),
                            stack_trace: None,
                        })],
                        resource_stats: ResourceStats {
                            cpu: CPUStats {
                                avg_usage_percent: 0.0,
                                peak_usage_percent: 0.0,
                                user_time: Duration::ZERO,
                                kernel_time: Duration::ZERO,
                                context_switches: 0,
                            },
                            memory: MemoryStats {
                                avg_usage_bytes: 0,
                                peak_usage_bytes: 0,
                                allocations: 0,
                                deallocations: 0,
                                page_faults: 0,
                            },
                            disk_io: DiskIOStats {
                                bytes_read: 0,
                                bytes_written: 0,
                                read_ops: 0,
                                write_ops: 0,
                            },
                            network_io: None,
                        },
                    };
                    implementation_results.insert(impl_config.id.clone(), failure_result);
                }
            }
        }
        
        // Stop resource monitoring
        let resource_usage = self.stop_resource_monitoring();
        
        let total_duration = start_time.elapsed().unwrap_or(Duration::ZERO);
        
        // Perform cross-implementation analysis
        let comparisons = self.generate_comparisons(&implementation_results);
        let statistical_summary = self.generate_statistical_summary(&implementation_results);
        let regression_analysis = self.perform_regression_analysis(&implementation_results);
        let recommendations = self.generate_recommendations(&implementation_results, &statistical_summary);
        
        // Create metadata
        let metadata = BenchmarkMetadata {
            timestamp: start_time,
            total_duration,
            config: self.config.clone(),
            system_info,
            git_commit: self.get_git_commit(),
            environment: std::env::vars().collect(),
        };
        
        let result = BenchmarkSuiteResult {
            metadata,
            implementation_results,
            comparisons,
            statistical_summary,
            regression_analysis,
            recommendations,
            resource_usage,
        };
        
        // Save results
        self.save_results(&result)?;
        
        println!("Benchmark suite completed in {:.2} seconds", total_duration.as_secs_f64());
        
        Ok(result)
    }
    
    /// Benchmark a single implementation
    fn benchmark_implementation(&self, impl_config: &ImplementationConfig) -> Result<ImplementationResult, Box<dyn std::error::Error>> {
        let mut category_results = HashMap::new();
        let mut all_failures = Vec::new();
        
        // Execute tests for each category
        for category in &self.config.test_categories {
            println!("  Category: {}", category.name);
            
            let mut test_results = Vec::new();
            let mut category_failures = Vec::new();
            
            for test_case in &category.tests {
                println!("    Test: {}", test_case.name);
                
                // Generate parameter combinations
                let param_combinations = self.generate_parameter_combinations(&test_case.parameters);
                
                for params in param_combinations {
                    match self.execute_single_test(impl_config, test_case, &params) {
                        Ok(result) => test_results.push(result),
                        Err(failure) => category_failures.push(failure),
                    }
                }
            }
            
            // Calculate category statistics
            let statistics = self.calculate_category_statistics(&test_results);
            let score = self.calculate_category_score(&test_results, category);
            
            category_results.insert(category.name.clone(), CategoryResult {
                category: category.name.clone(),
                test_results,
                score,
                statistics,
            });
            
            all_failures.extend(category_failures);
        }
        
        // Calculate overall score and ranking
        let overall_score = self.calculate_overall_score(&category_results);
        
        // Calculate resource statistics (placeholder)
        let resource_stats = self.calculate_resource_stats(impl_config);
        
        Ok(ImplementationResult {
            config: impl_config.clone(),
            category_results,
            overall_score,
            ranking: 0, // Will be set during comparison phase
            failures: all_failures,
            resource_stats,
        })
    }
    
    /// Execute a single test case
    fn execute_single_test(
        &self,
        impl_config: &ImplementationConfig,
        test_case: &TestCase,
        params: &HashMap<String, ParameterValue>,
    ) -> BenchmarkResult<TestResult> {
        // Generate the test code with parameter substitution
        let test_code = self.substitute_parameters(&test_case.code_template, params)?;
        
        // Create temporary test file
        let temp_file = self.create_temp_test_file(impl_config, &test_code)?;
        
        // Execute the test with timing and resource monitoring
        let (timing, memory, validation, success, error) = 
            self.execute_test_with_monitoring(impl_config, &temp_file, test_case)?;
        
        // Clean up temporary file
        let _ = fs::remove_file(&temp_file);
        
        if !success {
            return Err(Box::new(TestFailure {
                test_name: test_case.name.clone(),
                category: "unknown".to_string(), // Would be passed from caller
                parameters: params.clone(),
                reason: FailureReason::RuntimeError,
                error_message: error.unwrap_or_else(|| "Unknown error".to_string()),
                stack_trace: None,
            }));
        }
        
        Ok(TestResult {
            test_case: test_case.clone(),
            parameters: params.clone(),
            timing,
            memory,
            validation,
            success,
            error,
        })
    }
    
    /// Generate parameter combinations for a test
    fn generate_parameter_combinations(&self, parameters: &[TestParameter]) -> Vec<HashMap<String, ParameterValue>> {
        if parameters.is_empty() {
            return vec![HashMap::new()];
        }
        
        let mut combinations = vec![HashMap::new()];
        
        for param in parameters {
            let mut new_combinations = Vec::new();
            
            for value in &param.values {
                for existing_combo in &combinations {
                    let mut new_combo = existing_combo.clone();
                    new_combo.insert(param.name.clone(), value.clone());
                    new_combinations.push(new_combo);
                }
            }
            
            combinations = new_combinations;
        }
        
        combinations
    }
    
    /// Substitute parameters in test code template
    fn substitute_parameters(
        &self,
        template: &str,
        params: &HashMap<String, ParameterValue>,
    ) -> BenchmarkResult<String> {
        let mut result = template.to_string();
        
        for (name, value) in params {
            let placeholder = format!("{{{name}}}");
            let value_str = match value {
                ParameterValue::Integer { value } => value.to_string(),
                ParameterValue::Float { value } => value.to_string(),
                ParameterValue::String { value } => format!("\"{value}\""),
                ParameterValue::Boolean { value } => if *value { "#t" } else { "#f" }.to_string(),
                ParameterValue::Range { .. } => {
                    return Err(Box::new(TestFailure {
                        test_name: "parameter_substitution".to_string(),
                        category: "infrastructure".to_string(),
                        parameters: params.clone(),
                        reason: FailureReason::InfrastructureError,
                        error_message: "Range parameters should be expanded before substitution".to_string(),
                        stack_trace: None,
                    }));
                }
            };
            result = result.replace(&placeholder, &value_str);
        }
        
        Ok(result)
    }
    
    /// Create temporary test file for execution
    fn create_temp_test_file(
        &self,
        impl_config: &ImplementationConfig,
        test_code: &str,
    ) -> BenchmarkResult<String> {
        let file_extension = match &impl_config.runtime {
            RuntimeConfig::Lambdust { .. } => ".ldust",
            _ => ".scm",
        };
        
        let temp_file = format!("/tmp/benchmark_{}_{}{}", 
                               impl_config.id, 
                               SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_nanos(),
                               file_extension);
        
        fs::write(&temp_file, test_code).map_err(|e| TestFailure {
            test_name: "file_creation".to_string(),
            category: "infrastructure".to_string(),
            parameters: HashMap::new(),
            reason: FailureReason::InfrastructureError,
            error_message: format!("Failed to create temp file: {e}"),
            stack_trace: None,
        })?;
        
        Ok(temp_file)
    }
    
    /// Execute test with monitoring
    fn execute_test_with_monitoring(
        &self,
        impl_config: &ImplementationConfig,
        test_file: &str,
        test_case: &TestCase,
    ) -> BenchmarkResult<(TimingMeasurements, MemoryMeasurements, ValidationResult, bool, Option<String>)> {
        let mut iteration_times = Vec::new();
        let mut memory_measurements = Vec::new();
        
        // Warmup iterations
        for _ in 0..self.config.statistical_config.warmup_iterations {
            let _ = self.execute_single_iteration(impl_config, test_file, test_case)?;
        }
        
        // Actual measurement iterations
        for _ in 0..self.config.statistical_config.iterations {
            let start = Instant::now();
            let (success, error, memory_usage) = self.execute_single_iteration(impl_config, test_file, test_case)?;
            let duration = start.elapsed();
            
            if !success {
                return Ok((self.empty_timing(), self.empty_memory(), self.empty_validation(), false, error));
            }
            
            iteration_times.push(duration);
            memory_measurements.push((duration, memory_usage));
        }
        
        // Calculate timing statistics
        let timing = self.calculate_timing_statistics(iteration_times);
        
        // Calculate memory statistics
        let memory = self.calculate_memory_statistics(memory_measurements);
        
        // Validate result (simplified)
        let validation = ValidationResult {
            type_correct: true, // Placeholder
            value_correct: Some(true), // Placeholder
            actual_result: "result".to_string(), // Placeholder
            expected_result: None,
        };
        
        Ok((timing, memory, validation, true, None))
    }
    
    /// Execute a single iteration of a test
    fn execute_single_iteration(
        &self,
        impl_config: &ImplementationConfig,
        test_file: &str,
        _test_case: &TestCase,
    ) -> BenchmarkResult<(bool, Option<String>, u64)> {
        let mut cmd = match &impl_config.runtime {
            RuntimeConfig::Native { binary_path, args, env_vars } => {
                let mut command = Command::new(binary_path);
                command.args(args);
                for (key, value) in env_vars {
                    command.env(key, value);
                }
                command.arg(test_file);
                command
            }
            RuntimeConfig::Lambdust { target_dir, profile, .. } => {
                let binary_path = format!("{target_dir}/{profile}/lambdust");
                let mut command = Command::new(binary_path);
                command.arg("--batch");
                command.arg(test_file);
                command
            }
            RuntimeConfig::Docker { .. } => {
                // Docker execution would be implemented here
                return Err(Box::new(TestFailure {
                    test_name: "docker_execution".to_string(),
                    category: "infrastructure".to_string(),
                    parameters: HashMap::new(),
                    reason: FailureReason::InfrastructureError,
                    error_message: "Docker execution not yet implemented".to_string(),
                    stack_trace: None,
                }));
            }
        };
        
        match cmd.output() {
            Ok(output) => {
                let success = output.status.success();
                let error = if success {
                    None
                } else {
                    Some(String::from_utf8_lossy(&output.stderr).to_string())
                };
                
                // Memory usage estimation (placeholder)
                let memory_usage = output.stdout.len() as u64 + output.stderr.len() as u64;
                
                Ok((success, error, memory_usage))
            }
            Err(e) => Err(Box::new(TestFailure {
                test_name: "command_execution".to_string(),
                category: "infrastructure".to_string(),
                parameters: HashMap::new(),
                reason: FailureReason::InfrastructureError,
                error_message: format!("Failed to execute command: {e}"),
                stack_trace: None,
            })),
        }
    }
    
    // Placeholder implementations for statistics calculations
    fn calculate_timing_statistics(&self, times: Vec<Duration>) -> TimingMeasurements {
        if times.is_empty() {
            return self.empty_timing();
        }
        
        let sum: Duration = times.iter().sum();
        let mean = sum / times.len() as u32;
        
        let mut sorted_times = times.clone();
        sorted_times.sort();
        
        let median = sorted_times[sorted_times.len() / 2];
        let min = sorted_times[0];
        let max = sorted_times[sorted_times.len() - 1];
        
        // Standard deviation calculation
        let variance: f64 = times.iter()
            .map(|t| {
                let diff = t.as_secs_f64() - mean.as_secs_f64();
                diff * diff
            })
            .sum::<f64>() / times.len() as f64;
        let std_dev = Duration::from_secs_f64(variance.sqrt());
        
        // Percentiles
        let mut percentiles = HashMap::new();
        percentiles.insert(50, median);
        percentiles.insert(90, sorted_times[(sorted_times.len() * 90 / 100).min(sorted_times.len() - 1)]);
        percentiles.insert(95, sorted_times[(sorted_times.len() * 95 / 100).min(sorted_times.len() - 1)]);
        percentiles.insert(99, sorted_times[(sorted_times.len() * 99 / 100).min(sorted_times.len() - 1)]);
        
        // Operations per second
        let ops_per_second = 1.0 / mean.as_secs_f64();
        
        TimingMeasurements {
            iteration_times: times,
            mean,
            median,
            std_dev,
            min,
            max,
            percentiles,
            confidence_interval: TimingConfidenceInterval {
                lower: mean - std_dev,
                upper: mean + std_dev,
                confidence_level: self.config.statistical_config.confidence_level,
            },
            ops_per_second,
        }
    }
    
    fn calculate_memory_statistics(&self, measurements: Vec<(Duration, u64)>) -> MemoryMeasurements {
        if measurements.is_empty() {
            return self.empty_memory();
        }
        
        let peak_usage = measurements.iter().map(|(_, mem)| *mem).max().unwrap_or(0);
        let avg_usage = measurements.iter().map(|(_, mem)| *mem).sum::<u64>() / measurements.len() as u64;
        
        MemoryMeasurements {
            peak_usage,
            usage_timeline: measurements,
            allocation_rate: avg_usage as f64, // Simplified
            efficiency: if peak_usage > 0 { 1.0 / peak_usage as f64 } else { 0.0 },
        }
    }
    
    fn empty_timing(&self) -> TimingMeasurements {
        TimingMeasurements {
            iteration_times: Vec::new(),
            mean: Duration::ZERO,
            median: Duration::ZERO,
            std_dev: Duration::ZERO,
            min: Duration::ZERO,
            max: Duration::ZERO,
            percentiles: HashMap::new(),
            confidence_interval: TimingConfidenceInterval {
                lower: Duration::ZERO,
                upper: Duration::ZERO,
                confidence_level: 0.0,
            },
            ops_per_second: 0.0,
        }
    }
    
    fn empty_memory(&self) -> MemoryMeasurements {
        MemoryMeasurements {
            peak_usage: 0,
            usage_timeline: Vec::new(),
            allocation_rate: 0.0,
            efficiency: 0.0,
        }
    }
    
    fn empty_validation(&self) -> ValidationResult {
        ValidationResult {
            type_correct: false,
            value_correct: None,
            actual_result: String::new(),
            expected_result: None,
        }
    }
    
    // Additional placeholder implementations
    fn calculate_category_statistics(&self, _test_results: &[TestResult]) -> CategoryStatistics {
        CategoryStatistics {
            successful_tests: 0,
            total_tests: 0,
            success_rate: 0.0,
            avg_performance: 0.0,
            performance_variance: 0.0,
            category_ranking: 0,
        }
    }
    
    fn calculate_category_score(&self, _test_results: &[TestResult], _category: &TestCategory) -> f64 {
        75.0 // Placeholder
    }
    
    fn calculate_overall_score(&self, _category_results: &HashMap<String, CategoryResult>) -> f64 {
        75.0 // Placeholder
    }
    
    fn calculate_resource_stats(&self, _impl_config: &ImplementationConfig) -> ResourceStats {
        ResourceStats {
            cpu: CPUStats {
                avg_usage_percent: 50.0,
                peak_usage_percent: 80.0,
                user_time: Duration::from_secs(1),
                kernel_time: Duration::from_millis(100),
                context_switches: 1000,
            },
            memory: MemoryStats {
                avg_usage_bytes: 100 * 1024 * 1024,
                peak_usage_bytes: 200 * 1024 * 1024,
                allocations: 10000,
                deallocations: 9500,
                page_faults: 100,
            },
            disk_io: DiskIOStats {
                bytes_read: 1024 * 1024,
                bytes_written: 512 * 1024,
                read_ops: 100,
                write_ops: 50,
            },
            network_io: None,
        }
    }
    
    fn generate_comparisons(&self, _results: &HashMap<String, ImplementationResult>) -> Vec<ImplementationComparison> {
        Vec::new() // Placeholder
    }
    
    fn generate_statistical_summary(&self, _results: &HashMap<String, ImplementationResult>) -> StatisticalSummary {
        StatisticalSummary {
            performance_rankings: Vec::new(),
            category_leaders: HashMap::new(),
            distribution_stats: DistributionStats {
                distribution_shape: DistributionShape::Unknown,
                performance_variance: 0.0,
                outliers: Vec::new(),
            },
            correlation_analysis: CorrelationAnalysis {
                category_correlations: HashMap::new(),
                memory_speed_correlation: 0.0,
                feature_correlations: HashMap::new(),
            },
        }
    }
    
    fn perform_regression_analysis(&self, _results: &HashMap<String, ImplementationResult>) -> Option<RegressionAnalysis> {
        None // Placeholder
    }
    
    fn generate_recommendations(
        &self, 
        _results: &HashMap<String, ImplementationResult>,
        _summary: &StatisticalSummary,
    ) -> Vec<OptimizationRecommendation> {
        Vec::new() // Placeholder
    }
    
    fn collect_system_info(&self) -> SystemInfo {
        SystemInfo {
            os: std::env::consts::OS.to_string(),
            architecture: std::env::consts::ARCH.to_string(),
            cpu_model: "Unknown".to_string(), // Would use system API
            cpu_cores: num_cpus::get() as u32,
            total_memory_mb: 8192, // Placeholder
            available_memory_mb: 4096, // Placeholder
            hostname: "benchmark-host".to_string(),
        }
    }
    
    fn get_git_commit(&self) -> Option<String> {
        // Would execute `git rev-parse HEAD`
        None
    }
    
    fn start_resource_monitoring(&self) {
        // Would start background thread for resource monitoring
    }
    
    fn stop_resource_monitoring(&self) -> SystemResourceUsage {
        // Would stop monitoring and return collected data
        SystemResourceUsage {
            timeline: Vec::new(),
            peak_usage: ResourceSnapshot {
                timestamp: SystemTime::now(),
                cpu_percent: 80.0,
                memory_bytes: 200 * 1024 * 1024,
                available_memory_bytes: 6000 * 1024 * 1024,
                disk_io_rate: 1024.0 * 1024.0,
                network_io_rate: 0.0,
                process_count: 10,
            },
            average_usage: ResourceSnapshot {
                timestamp: SystemTime::now(),
                cpu_percent: 50.0,
                memory_bytes: 100 * 1024 * 1024,
                available_memory_bytes: 7000 * 1024 * 1024,
                disk_io_rate: 512.0 * 1024.0,
                network_io_rate: 0.0,
                process_count: 8,
            },
            efficiency_metrics: ResourceEfficiency {
                cpu_efficiency: 0.75,
                memory_efficiency: 0.80,
                overall_efficiency: 0.77,
                bottlenecks: vec!["CPU-bound".to_string()],
            },
        }
    }
    
    fn save_results(&self, result: &BenchmarkSuiteResult) -> Result<(), Box<dyn std::error::Error>> {
        // Create output directory
        fs::create_dir_all(&self.config.output_config.output_dir)?;
        
        let timestamp = result.metadata.timestamp
            .duration_since(UNIX_EPOCH)?
            .as_secs();
        
        // Save results in requested formats
        for format in &self.config.output_config.formats {
            match format {
                OutputFormat::JSON => {
                    let json_path = format!("{}/benchmark_results_{}.json", 
                                          self.config.output_config.output_dir, timestamp);
                    let json_data = serde_json::to_string_pretty(result)?;
                    fs::write(json_path, json_data)?;
                }
                OutputFormat::CSV => {
                    let csv_path = format!("{}/benchmark_results_{}.csv", 
                                         self.config.output_config.output_dir, timestamp);
                    // CSV generation would be implemented here
                    fs::write(csv_path, "CSV data placeholder")?;
                }
                OutputFormat::HTML => {
                    let html_path = format!("{}/benchmark_report_{}.html", 
                                          self.config.output_config.output_dir, timestamp);
                    let html_report = self.generate_html_report(result);
                    fs::write(html_path, html_report)?;
                }
                _ => {
                    // Other formats would be implemented here
                }
            }
        }
        
        Ok(())
    }
    
    fn generate_html_report(&self, result: &BenchmarkSuiteResult) -> String {
        format!(r#"
<!DOCTYPE html>
<html>
<head>
    <title>Lambdust Benchmark Results</title>
    <style>
        body {{ font-family: Arial, sans-serif; margin: 40px; }}
        .summary {{ background-color: #f5f5f5; padding: 20px; border-radius: 5px; }}
        .implementation {{ margin: 20px 0; padding: 15px; border: 1px solid #ddd; }}
        .score {{ font-size: 1.2em; font-weight: bold; color: #2e7d32; }}
    </style>
</head>
<body>
    <h1>Lambdust Performance Benchmark Results</h1>
    
    <div class="summary">
        <h2>Summary</h2>
        <p><strong>Benchmark Date:</strong> {}</p>
        <p><strong>Total Duration:</strong> {:.2} seconds</p>
        <p><strong>Implementations Tested:</strong> {}</p>
    </div>
    
    <h2>Implementation Results</h2>
    {}
    
    <h2>System Information</h2>
    <p><strong>OS:</strong> {}</p>
    <p><strong>Architecture:</strong> {}</p>
    <p><strong>CPU Cores:</strong> {}</p>
    <p><strong>Memory:</strong> {} MB</p>
</body>
</html>
        "#,
        // Format timestamp
        result.metadata.timestamp.duration_since(UNIX_EPOCH).unwrap().as_secs(),
        result.metadata.total_duration.as_secs_f64(),
        result.implementation_results.len(),
        // Implementation results
        result.implementation_results.iter()
            .map(|(id, impl_result)| format!(r#"
                <div class="implementation">
                    <h3>{}</h3>
                    <p class="score">Overall Score: {:.1}/100</p>
                    <p><strong>Ranking:</strong> #{}</p>
                    <p><strong>Failures:</strong> {}</p>
                </div>
            "#, impl_result.config.name, impl_result.overall_score, impl_result.ranking, impl_result.failures.len()))
            .collect::<Vec<String>>()
            .join(""),
        result.metadata.system_info.os,
        result.metadata.system_info.architecture,
        result.metadata.system_info.cpu_cores,
        result.metadata.system_info.total_memory_mb
        )
    }
}

/// Convenience function to run benchmark suite with default configuration
pub fn run_comprehensive_benchmarks() -> Result<BenchmarkSuiteResult, Box<dyn std::error::Error>> {
    let config = BenchmarkSuiteConfig::default();
    let mut suite = ComprehensiveBenchmarkSuite::new(config);
    suite.execute()
}

/// Load configuration from file
pub fn load_benchmark_config(path: &str) -> Result<BenchmarkSuiteConfig, Box<dyn std::error::Error>> {
    let content = fs::read_to_string(path)?;
    let config: BenchmarkSuiteConfig = serde_json::from_str(&content)?;
    Ok(config)
}

/// Save configuration to file
pub fn save_benchmark_config(config: &BenchmarkSuiteConfig, path: &str) -> Result<(), Box<dyn std::error::Error>> {
    let content = serde_json::to_string_pretty(config)?;
    fs::write(path, content)?;
    Ok(())
}

#[cfg(test)]
mod tests {
    use super::*;
    
    #[test]
    fn test_config_creation() {
        let config = BenchmarkSuiteConfig::default();
        assert!(!config.implementations.is_empty());
        assert!(!config.test_categories.is_empty());
    }
    
    #[test]
    fn test_parameter_combination_generation() {
        let suite = ComprehensiveBenchmarkSuite::new(BenchmarkSuiteConfig::default());
        
        let params = vec![
            TestParameter {
                name: "n".to_string(),
                values: vec![
                    ParameterValue::Integer { value: 10 },
                    ParameterValue::Integer { value: 20 },
                ],
                scaling_behavior: ScalingBehavior::Linear,
            },
            TestParameter {
                name: "m".to_string(),
                values: vec![
                    ParameterValue::Integer { value: 5 },
                ],
                scaling_behavior: ScalingBehavior::Constant,
            },
        ];
        
        let combinations = suite.generate_parameter_combinations(&params);
        assert_eq!(combinations.len(), 2); // 2 * 1 = 2 combinations
    }
    
    #[test]
    fn test_parameter_substitution() {
        let suite = ComprehensiveBenchmarkSuite::new(BenchmarkSuiteConfig::default());
        
        let template = "(test {n} {s})";
        let mut params = HashMap::new();
        params.insert("n".to_string(), ParameterValue::Integer { value: 42 });
        params.insert("s".to_string(), ParameterValue::String { value: "hello".to_string() });
        
        let result = suite.substitute_parameters(template, &params).unwrap();
        assert_eq!(result, "(test 42 \"hello\")");
    }
}