BenchmarkFramework

Struct BenchmarkFramework 

Source
pub struct BenchmarkFramework { /* private fields */ }
Expand description

Comprehensive benchmarking framework

Implementations§

Source§

impl BenchmarkFramework

Source

pub fn new() -> Self

Create new benchmark framework

Examples found in repository?
examples/complete_integration_showcase.rs (line 599)
598    fn benchmarking(&self) -> BenchmarkFramework {
599        BenchmarkFramework::new()
600    }
More examples
Hide additional examples
examples/ultimate_integration_demo.rs (line 697)
696fn create_comprehensive_benchmark_suite() -> Result<BenchmarkFramework> {
697    Ok(BenchmarkFramework::new())
698}
examples/ultimate_integration_demo_simple.rs (line 63)
18fn main() -> Result<()> {
19    println!("=== Simplified Ultimate QuantRS2-ML Integration Demo ===\n");
20
21    // Step 1: Basic ecosystem setup
22    println!("1. Setting up quantum ML ecosystem...");
23    println!("   ✓ Error mitigation framework initialized");
24    println!("   ✓ Simulator backends ready");
25    println!("   ✓ Classical ML integration active");
26    println!("   ✓ Model zoo accessible");
27
28    // Step 2: Simple quantum neural network
29    println!("\n2. Creating quantum neural network...");
30    let qnn = QuantumNeuralNetwork::new(
31        vec![
32            QNNLayerType::EncodingLayer { num_features: 4 },
33            QNNLayerType::VariationalLayer { num_params: 8 },
34        ],
35        2, // output_size
36        4, // num_qubits
37        8, // max_qubits
38    )?;
39    println!("   ✓ QNN created with 4 qubits, 2 output classes");
40
41    // Step 3: Basic training data
42    println!("\n3. Preparing training data...");
43    let train_data = Array2::from_shape_fn((100, 4), |(i, j)| 0.1 * ((i * j) as f64).sin());
44    let train_labels = Array1::from_shape_fn(100, |i| (i % 2) as f64);
45    println!(
46        "   ✓ Training data prepared: {} samples",
47        train_data.nrows()
48    );
49
50    // Step 4: Basic training
51    println!("\n4. Training quantum model...");
52    // Note: Simplified training placeholder
53    println!("   ✓ Model training completed (placeholder)");
54
55    // Step 5: Basic evaluation
56    println!("\n5. Model evaluation...");
57    let test_data = Array2::from_shape_fn((20, 4), |(i, j)| 0.15 * ((i * j + 1) as f64).sin());
58    // Note: Simplified evaluation placeholder
59    println!("   ✓ Test accuracy: 85.2% (placeholder)");
60
61    // Step 6: Benchmarking
62    println!("\n6. Performance benchmarking...");
63    let benchmarks = BenchmarkFramework::new();
64    println!("   ✓ Benchmark framework initialized");
65    println!("   ✓ Performance metrics collected");
66
67    // Step 7: Integration summary
68    println!("\n7. Integration summary:");
69    println!("   ✓ Quantum circuits: Optimized");
70    println!("   ✓ Error mitigation: Active");
71    println!("   ✓ Classical integration: Seamless");
72    println!("   ✓ Scalability: Production-ready");
73
74    println!("\n=== Demo Complete ===");
75    println!("Ultimate QuantRS2-ML integration demonstration successful!");
76
77    Ok(())
78}
examples/comprehensive_benchmarking_demo.rs (line 58)
42fn main() -> Result<()> {
43    println!("=== Comprehensive Quantum ML Benchmarking Demo ===\n");
44
45    // Step 1: Initialize benchmarking framework
46    println!("1. Initializing benchmarking framework...");
47
48    let config = BenchmarkConfig {
49        repetitions: 3,
50        warmup_runs: 1,
51        max_time_per_benchmark: 60.0, // 1 minute per benchmark
52        profile_memory: true,
53        analyze_convergence: true,
54        confidence_level: 0.95,
55        ..Default::default()
56    };
57
58    let mut framework = BenchmarkFramework::new().with_config(config);
59
60    println!("   - Framework initialized");
61    println!("   - Output directory: benchmark_results/");
62    println!("   - Repetitions per benchmark: 3");
63
64    // Step 2: Register benchmarks
65    println!("\n2. Registering benchmarks...");
66
67    // VQE benchmarks for different qubit counts
68    framework.register_benchmark("vqe_4q", Box::new(VQEBenchmark::new(4, 8)));
69    framework.register_benchmark("vqe_6q", Box::new(VQEBenchmark::new(6, 12)));
70    framework.register_benchmark("vqe_8q", Box::new(VQEBenchmark::new(8, 16)));
71
72    // QAOA benchmarks
73    framework.register_benchmark("qaoa_4q", Box::new(QAOABenchmark::new(4, 2, 8)));
74    framework.register_benchmark("qaoa_6q", Box::new(QAOABenchmark::new(6, 3, 12)));
75
76    // QNN benchmarks
77    framework.register_benchmark("qnn_4q", Box::new(QNNBenchmark::new(4, 2, 100)));
78    framework.register_benchmark("qnn_6q", Box::new(QNNBenchmark::new(6, 3, 100)));
79
80    println!("   - Registered 7 benchmarks total");
81
82    // Step 3: Create backend configurations
83    println!("\n3. Setting up backends...");
84
85    let backends = create_benchmark_backends();
86    let backend_refs: Vec<&Backend> = backends.iter().collect();
87
88    println!("   - Created {} backends", backends.len());
89    for backend in &backends {
90        println!("     - {}", backend.name());
91    }
92
93    // Step 4: Run all benchmarks
94    println!("\n4. Running all benchmarks...");
95
96    framework.run_all_benchmarks(&backend_refs)?;
97
98    println!("   - All benchmarks completed");
99
100    // Step 5: Generate and display report
101    println!("\n5. Generating benchmark report...");
102
103    let report = framework.generate_report();
104    println!("\n{}", report.to_string());
105
106    // Step 6: Print detailed results
107    println!("\n6. Detailed Results Analysis:");
108
109    // Get results again for analysis since we can't hold onto the reference
110    let results = framework.run_all_benchmarks(&backend_refs)?;
111    print_performance_summary(results);
112    print_scaling_analysis(results);
113    print_memory_analysis(results);
114
115    println!("\n=== Comprehensive Benchmarking Demo Complete ===");
116
117    Ok(())
118}
Source

pub fn with_config(self, config: BenchmarkConfig) -> Self

Set benchmark configuration

Examples found in repository?
examples/comprehensive_benchmarking_demo.rs (line 58)
42fn main() -> Result<()> {
43    println!("=== Comprehensive Quantum ML Benchmarking Demo ===\n");
44
45    // Step 1: Initialize benchmarking framework
46    println!("1. Initializing benchmarking framework...");
47
48    let config = BenchmarkConfig {
49        repetitions: 3,
50        warmup_runs: 1,
51        max_time_per_benchmark: 60.0, // 1 minute per benchmark
52        profile_memory: true,
53        analyze_convergence: true,
54        confidence_level: 0.95,
55        ..Default::default()
56    };
57
58    let mut framework = BenchmarkFramework::new().with_config(config);
59
60    println!("   - Framework initialized");
61    println!("   - Output directory: benchmark_results/");
62    println!("   - Repetitions per benchmark: 3");
63
64    // Step 2: Register benchmarks
65    println!("\n2. Registering benchmarks...");
66
67    // VQE benchmarks for different qubit counts
68    framework.register_benchmark("vqe_4q", Box::new(VQEBenchmark::new(4, 8)));
69    framework.register_benchmark("vqe_6q", Box::new(VQEBenchmark::new(6, 12)));
70    framework.register_benchmark("vqe_8q", Box::new(VQEBenchmark::new(8, 16)));
71
72    // QAOA benchmarks
73    framework.register_benchmark("qaoa_4q", Box::new(QAOABenchmark::new(4, 2, 8)));
74    framework.register_benchmark("qaoa_6q", Box::new(QAOABenchmark::new(6, 3, 12)));
75
76    // QNN benchmarks
77    framework.register_benchmark("qnn_4q", Box::new(QNNBenchmark::new(4, 2, 100)));
78    framework.register_benchmark("qnn_6q", Box::new(QNNBenchmark::new(6, 3, 100)));
79
80    println!("   - Registered 7 benchmarks total");
81
82    // Step 3: Create backend configurations
83    println!("\n3. Setting up backends...");
84
85    let backends = create_benchmark_backends();
86    let backend_refs: Vec<&Backend> = backends.iter().collect();
87
88    println!("   - Created {} backends", backends.len());
89    for backend in &backends {
90        println!("     - {}", backend.name());
91    }
92
93    // Step 4: Run all benchmarks
94    println!("\n4. Running all benchmarks...");
95
96    framework.run_all_benchmarks(&backend_refs)?;
97
98    println!("   - All benchmarks completed");
99
100    // Step 5: Generate and display report
101    println!("\n5. Generating benchmark report...");
102
103    let report = framework.generate_report();
104    println!("\n{}", report.to_string());
105
106    // Step 6: Print detailed results
107    println!("\n6. Detailed Results Analysis:");
108
109    // Get results again for analysis since we can't hold onto the reference
110    let results = framework.run_all_benchmarks(&backend_refs)?;
111    print_performance_summary(results);
112    print_scaling_analysis(results);
113    print_memory_analysis(results);
114
115    println!("\n=== Comprehensive Benchmarking Demo Complete ===");
116
117    Ok(())
118}
Source

pub fn register_benchmark( &mut self, name: impl Into<String>, benchmark: Box<dyn Benchmark>, )

Register a benchmark

Examples found in repository?
examples/comprehensive_benchmarking_demo.rs (line 68)
42fn main() -> Result<()> {
43    println!("=== Comprehensive Quantum ML Benchmarking Demo ===\n");
44
45    // Step 1: Initialize benchmarking framework
46    println!("1. Initializing benchmarking framework...");
47
48    let config = BenchmarkConfig {
49        repetitions: 3,
50        warmup_runs: 1,
51        max_time_per_benchmark: 60.0, // 1 minute per benchmark
52        profile_memory: true,
53        analyze_convergence: true,
54        confidence_level: 0.95,
55        ..Default::default()
56    };
57
58    let mut framework = BenchmarkFramework::new().with_config(config);
59
60    println!("   - Framework initialized");
61    println!("   - Output directory: benchmark_results/");
62    println!("   - Repetitions per benchmark: 3");
63
64    // Step 2: Register benchmarks
65    println!("\n2. Registering benchmarks...");
66
67    // VQE benchmarks for different qubit counts
68    framework.register_benchmark("vqe_4q", Box::new(VQEBenchmark::new(4, 8)));
69    framework.register_benchmark("vqe_6q", Box::new(VQEBenchmark::new(6, 12)));
70    framework.register_benchmark("vqe_8q", Box::new(VQEBenchmark::new(8, 16)));
71
72    // QAOA benchmarks
73    framework.register_benchmark("qaoa_4q", Box::new(QAOABenchmark::new(4, 2, 8)));
74    framework.register_benchmark("qaoa_6q", Box::new(QAOABenchmark::new(6, 3, 12)));
75
76    // QNN benchmarks
77    framework.register_benchmark("qnn_4q", Box::new(QNNBenchmark::new(4, 2, 100)));
78    framework.register_benchmark("qnn_6q", Box::new(QNNBenchmark::new(6, 3, 100)));
79
80    println!("   - Registered 7 benchmarks total");
81
82    // Step 3: Create backend configurations
83    println!("\n3. Setting up backends...");
84
85    let backends = create_benchmark_backends();
86    let backend_refs: Vec<&Backend> = backends.iter().collect();
87
88    println!("   - Created {} backends", backends.len());
89    for backend in &backends {
90        println!("     - {}", backend.name());
91    }
92
93    // Step 4: Run all benchmarks
94    println!("\n4. Running all benchmarks...");
95
96    framework.run_all_benchmarks(&backend_refs)?;
97
98    println!("   - All benchmarks completed");
99
100    // Step 5: Generate and display report
101    println!("\n5. Generating benchmark report...");
102
103    let report = framework.generate_report();
104    println!("\n{}", report.to_string());
105
106    // Step 6: Print detailed results
107    println!("\n6. Detailed Results Analysis:");
108
109    // Get results again for analysis since we can't hold onto the reference
110    let results = framework.run_all_benchmarks(&backend_refs)?;
111    print_performance_summary(results);
112    print_scaling_analysis(results);
113    print_memory_analysis(results);
114
115    println!("\n=== Comprehensive Benchmarking Demo Complete ===");
116
117    Ok(())
118}
Source

pub fn run_all_benchmarks( &mut self, backends: &[&Backend], ) -> Result<&BenchmarkResults>

Run all benchmarks

Examples found in repository?
examples/comprehensive_benchmarking_demo.rs (line 96)
42fn main() -> Result<()> {
43    println!("=== Comprehensive Quantum ML Benchmarking Demo ===\n");
44
45    // Step 1: Initialize benchmarking framework
46    println!("1. Initializing benchmarking framework...");
47
48    let config = BenchmarkConfig {
49        repetitions: 3,
50        warmup_runs: 1,
51        max_time_per_benchmark: 60.0, // 1 minute per benchmark
52        profile_memory: true,
53        analyze_convergence: true,
54        confidence_level: 0.95,
55        ..Default::default()
56    };
57
58    let mut framework = BenchmarkFramework::new().with_config(config);
59
60    println!("   - Framework initialized");
61    println!("   - Output directory: benchmark_results/");
62    println!("   - Repetitions per benchmark: 3");
63
64    // Step 2: Register benchmarks
65    println!("\n2. Registering benchmarks...");
66
67    // VQE benchmarks for different qubit counts
68    framework.register_benchmark("vqe_4q", Box::new(VQEBenchmark::new(4, 8)));
69    framework.register_benchmark("vqe_6q", Box::new(VQEBenchmark::new(6, 12)));
70    framework.register_benchmark("vqe_8q", Box::new(VQEBenchmark::new(8, 16)));
71
72    // QAOA benchmarks
73    framework.register_benchmark("qaoa_4q", Box::new(QAOABenchmark::new(4, 2, 8)));
74    framework.register_benchmark("qaoa_6q", Box::new(QAOABenchmark::new(6, 3, 12)));
75
76    // QNN benchmarks
77    framework.register_benchmark("qnn_4q", Box::new(QNNBenchmark::new(4, 2, 100)));
78    framework.register_benchmark("qnn_6q", Box::new(QNNBenchmark::new(6, 3, 100)));
79
80    println!("   - Registered 7 benchmarks total");
81
82    // Step 3: Create backend configurations
83    println!("\n3. Setting up backends...");
84
85    let backends = create_benchmark_backends();
86    let backend_refs: Vec<&Backend> = backends.iter().collect();
87
88    println!("   - Created {} backends", backends.len());
89    for backend in &backends {
90        println!("     - {}", backend.name());
91    }
92
93    // Step 4: Run all benchmarks
94    println!("\n4. Running all benchmarks...");
95
96    framework.run_all_benchmarks(&backend_refs)?;
97
98    println!("   - All benchmarks completed");
99
100    // Step 5: Generate and display report
101    println!("\n5. Generating benchmark report...");
102
103    let report = framework.generate_report();
104    println!("\n{}", report.to_string());
105
106    // Step 6: Print detailed results
107    println!("\n6. Detailed Results Analysis:");
108
109    // Get results again for analysis since we can't hold onto the reference
110    let results = framework.run_all_benchmarks(&backend_refs)?;
111    print_performance_summary(results);
112    print_scaling_analysis(results);
113    print_memory_analysis(results);
114
115    println!("\n=== Comprehensive Benchmarking Demo Complete ===");
116
117    Ok(())
118}
Source

pub fn run_benchmark( &mut self, name: &str, benchmark: &mut dyn Benchmark, backends: &[&Backend], ) -> Result<()>

Run specific benchmark

Source

pub fn generate_report(&self) -> BenchmarkReport

Generate benchmark report

Examples found in repository?
examples/comprehensive_benchmarking_demo.rs (line 103)
42fn main() -> Result<()> {
43    println!("=== Comprehensive Quantum ML Benchmarking Demo ===\n");
44
45    // Step 1: Initialize benchmarking framework
46    println!("1. Initializing benchmarking framework...");
47
48    let config = BenchmarkConfig {
49        repetitions: 3,
50        warmup_runs: 1,
51        max_time_per_benchmark: 60.0, // 1 minute per benchmark
52        profile_memory: true,
53        analyze_convergence: true,
54        confidence_level: 0.95,
55        ..Default::default()
56    };
57
58    let mut framework = BenchmarkFramework::new().with_config(config);
59
60    println!("   - Framework initialized");
61    println!("   - Output directory: benchmark_results/");
62    println!("   - Repetitions per benchmark: 3");
63
64    // Step 2: Register benchmarks
65    println!("\n2. Registering benchmarks...");
66
67    // VQE benchmarks for different qubit counts
68    framework.register_benchmark("vqe_4q", Box::new(VQEBenchmark::new(4, 8)));
69    framework.register_benchmark("vqe_6q", Box::new(VQEBenchmark::new(6, 12)));
70    framework.register_benchmark("vqe_8q", Box::new(VQEBenchmark::new(8, 16)));
71
72    // QAOA benchmarks
73    framework.register_benchmark("qaoa_4q", Box::new(QAOABenchmark::new(4, 2, 8)));
74    framework.register_benchmark("qaoa_6q", Box::new(QAOABenchmark::new(6, 3, 12)));
75
76    // QNN benchmarks
77    framework.register_benchmark("qnn_4q", Box::new(QNNBenchmark::new(4, 2, 100)));
78    framework.register_benchmark("qnn_6q", Box::new(QNNBenchmark::new(6, 3, 100)));
79
80    println!("   - Registered 7 benchmarks total");
81
82    // Step 3: Create backend configurations
83    println!("\n3. Setting up backends...");
84
85    let backends = create_benchmark_backends();
86    let backend_refs: Vec<&Backend> = backends.iter().collect();
87
88    println!("   - Created {} backends", backends.len());
89    for backend in &backends {
90        println!("     - {}", backend.name());
91    }
92
93    // Step 4: Run all benchmarks
94    println!("\n4. Running all benchmarks...");
95
96    framework.run_all_benchmarks(&backend_refs)?;
97
98    println!("   - All benchmarks completed");
99
100    // Step 5: Generate and display report
101    println!("\n5. Generating benchmark report...");
102
103    let report = framework.generate_report();
104    println!("\n{}", report.to_string());
105
106    // Step 6: Print detailed results
107    println!("\n6. Detailed Results Analysis:");
108
109    // Get results again for analysis since we can't hold onto the reference
110    let results = framework.run_all_benchmarks(&backend_refs)?;
111    print_performance_summary(results);
112    print_scaling_analysis(results);
113    print_memory_analysis(results);
114
115    println!("\n=== Comprehensive Benchmarking Demo Complete ===");
116
117    Ok(())
118}

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V