pub struct BenchmarkResults { /* private fields */ }Expand description
Aggregated benchmark results
Implementations§
Source§impl BenchmarkResults
impl BenchmarkResults
Sourcepub fn summaries(&self) -> &HashMap<String, BenchmarkSummary>
pub fn summaries(&self) -> &HashMap<String, BenchmarkSummary>
Get summaries
Examples found in repository?
examples/comprehensive_benchmarking_demo.rs (line 117)
112fn print_performance_summary(results: &BenchmarkResults) {
113 println!("\n Performance Summary:");
114 println!(" ===================");
115
116 // Print summaries for each benchmark
117 for (name, summary) in results.summaries() {
118 println!(" {name}:");
119 println!(" - Mean time: {:.3}s", summary.mean_time.as_secs_f64());
120 println!(" - Min time: {:.3}s", summary.min_time.as_secs_f64());
121 println!(" - Max time: {:.3}s", summary.max_time.as_secs_f64());
122 println!(" - Success rate: {:.1}%", summary.success_rate * 100.0);
123 if let Some(memory) = summary.mean_memory {
124 println!(
125 " - Memory usage: {:.1} MB",
126 memory as f64 / 1024.0 / 1024.0
127 );
128 }
129 println!();
130 }
131}
132
133fn print_scaling_analysis(results: &BenchmarkResults) {
134 println!(" Scaling Analysis:");
135 println!(" =================");
136
137 // Group by algorithm type
138 let mut vqe_results = Vec::new();
139 let mut qaoa_results = Vec::new();
140 let mut qnn_results = Vec::new();
141
142 for (name, summary) in results.summaries() {
143 if name.starts_with("vqe_") {
144 vqe_results.push((name, summary));
145 } else if name.starts_with("qaoa_") {
146 qaoa_results.push((name, summary));
147 } else if name.starts_with("qnn_") {
148 qnn_results.push((name, summary));
149 }
150 }
151
152 // Analyze VQE scaling
153 if !vqe_results.is_empty() {
154 println!(" VQE Algorithm Scaling:");
155 vqe_results.sort_by_key(|(name, _)| (*name).to_string());
156 for (name, summary) in vqe_results {
157 let qubits = extract_qubit_count(name);
158 println!(
159 " - {} qubits: {:.3}s",
160 qubits,
161 summary.mean_time.as_secs_f64()
162 );
163 }
164 println!(" - Scaling trend: Exponential (as expected for VQE)");
165 println!();
166 }
167
168 // Analyze QAOA scaling
169 if !qaoa_results.is_empty() {
170 println!(" QAOA Algorithm Scaling:");
171 qaoa_results.sort_by_key(|(name, _)| (*name).to_string());
172 for (name, summary) in qaoa_results {
173 let qubits = extract_qubit_count(name);
174 println!(
175 " - {} qubits: {:.3}s",
176 qubits,
177 summary.mean_time.as_secs_f64()
178 );
179 }
180 println!(" - Scaling trend: Polynomial (as expected for QAOA)");
181 println!();
182 }
183
184 // Analyze QNN scaling
185 if !qnn_results.is_empty() {
186 println!(" QNN Algorithm Scaling:");
187 qnn_results.sort_by_key(|(name, _)| (*name).to_string());
188 for (name, summary) in qnn_results {
189 let qubits = extract_qubit_count(name);
190 println!(
191 " - {} qubits: {:.3}s",
192 qubits,
193 summary.mean_time.as_secs_f64()
194 );
195 }
196 println!(" - Scaling trend: Polynomial (training overhead)");
197 println!();
198 }
199}
200
201fn print_memory_analysis(results: &BenchmarkResults) {
202 println!(" Memory Usage Analysis:");
203 println!(" =====================");
204
205 let mut memory_data = Vec::new();
206 for (name, summary) in results.summaries() {
207 if let Some(memory) = summary.mean_memory {
208 let qubits = extract_qubit_count(name);
209 memory_data.push((qubits, memory, name));
210 }
211 }
212
213 if !memory_data.is_empty() {
214 memory_data.sort_by_key(|(qubits, _, _)| *qubits);
215
216 println!(" Memory scaling by qubit count:");
217 for (qubits, memory, name) in memory_data {
218 println!(
219 " - {} qubits ({}): {:.1} MB",
220 qubits,
221 name,
222 memory as f64 / 1024.0 / 1024.0
223 );
224 }
225 println!(" - Expected scaling: O(2^n) for statevector simulation");
226 println!();
227 }
228
229 // Print recommendations
230 println!(" Recommendations:");
231 println!(" - Use statevector backend for circuits ≤ 12 qubits");
232 println!(" - Use MPS backend for larger circuits with limited entanglement");
233 println!(" - Consider circuit optimization for memory-constrained environments");
234}
235
236fn extract_qubit_count(benchmark_name: &str) -> usize {
237 // Extract number from strings like "vqe_4q_statevector", "qaoa_6q_mps", etc.
238 for part in benchmark_name.split('_') {
239 if part.ends_with('q') {
240 if let Ok(num) = part.trim_end_matches('q').parse::<usize>() {
241 return num;
242 }
243 }
244 }
245 0 // Default if not found
246}
247
248// Additional analysis functions
249fn analyze_backend_performance(results: &BenchmarkResults) {
250 println!(" Backend Performance Comparison:");
251 println!(" ==============================");
252
253 // Group results by backend type
254 let mut backend_performance = std::collections::HashMap::new();
255
256 for (name, summary) in results.summaries() {
257 let backend_type = extract_backend_type(name);
258 backend_performance
259 .entry(backend_type)
260 .or_insert_with(Vec::new)
261 .push(summary.mean_time.as_secs_f64());
262 }
263
264 for (backend, times) in backend_performance {
265 let avg_time = times.iter().sum::<f64>() / times.len() as f64;
266 println!(" - {backend} backend: {avg_time:.3}s average");
267 }
268}Sourcepub fn metadata(&self) -> &BenchmarkMetadata
pub fn metadata(&self) -> &BenchmarkMetadata
Get metadata
Trait Implementations§
Source§impl Clone for BenchmarkResults
impl Clone for BenchmarkResults
Source§fn clone(&self) -> BenchmarkResults
fn clone(&self) -> BenchmarkResults
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for BenchmarkResults
impl RefUnwindSafe for BenchmarkResults
impl Send for BenchmarkResults
impl Sync for BenchmarkResults
impl Unpin for BenchmarkResults
impl UnwindSafe for BenchmarkResults
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
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
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
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.