add sbp xi/eta benches
This commit is contained in:
		@@ -27,3 +27,7 @@ harness = false
 | 
				
			|||||||
[[bench]]
 | 
					[[bench]]
 | 
				
			||||||
name = "euler"
 | 
					name = "euler"
 | 
				
			||||||
harness = false
 | 
					harness = false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[[bench]]
 | 
				
			||||||
 | 
					name = "sbpoperators"
 | 
				
			||||||
 | 
					harness = false
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										52
									
								
								sbp/benches/sbpoperators.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								sbp/benches/sbpoperators.rs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,52 @@
 | 
				
			|||||||
 | 
					use criterion::{criterion_group, criterion_main, Criterion};
 | 
				
			||||||
 | 
					use sbp::operators::{self, SbpOperator2d};
 | 
				
			||||||
 | 
					use sbp::Float;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					fn performance_benchmark(c: &mut Criterion) {
 | 
				
			||||||
 | 
					    let mut group = c.benchmark_group("SBPoperators");
 | 
				
			||||||
 | 
					    group.sample_size(25);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    let w = 64;
 | 
				
			||||||
 | 
					    let h = 64;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    let x = ndarray::Array2::from_shape_fn((w, h), |(j, i)| (j * h + i) as Float);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    group.bench_function("upwind4 diffxi", |b| {
 | 
				
			||||||
 | 
					        let mut res = x.clone();
 | 
				
			||||||
 | 
					        b.iter(|| operators::Upwind4.diffxi(x.view(), res.view_mut()))
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					    group.bench_function("upwind9 diffxi", |b| {
 | 
				
			||||||
 | 
					        let mut res = x.clone();
 | 
				
			||||||
 | 
					        b.iter(|| operators::Upwind9.diffxi(x.view(), res.view_mut()))
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					    group.bench_function("trad4 diffxi", |b| {
 | 
				
			||||||
 | 
					        let mut res = x.clone();
 | 
				
			||||||
 | 
					        b.iter(|| operators::SBP4.diffxi(x.view(), res.view_mut()))
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					    group.bench_function("trad8 diffxi", |b| {
 | 
				
			||||||
 | 
					        let mut res = x.clone();
 | 
				
			||||||
 | 
					        b.iter(|| operators::SBP8.diffxi(x.view(), res.view_mut()))
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    group.bench_function("upwind4 diffeta", |b| {
 | 
				
			||||||
 | 
					        let mut res = x.clone();
 | 
				
			||||||
 | 
					        b.iter(|| operators::Upwind4.diffeta(x.view(), res.view_mut()))
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					    group.bench_function("upwind9 diffeta", |b| {
 | 
				
			||||||
 | 
					        let mut res = x.clone();
 | 
				
			||||||
 | 
					        b.iter(|| operators::Upwind9.diffeta(x.view(), res.view_mut()))
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					    group.bench_function("trad4 diffeta", |b| {
 | 
				
			||||||
 | 
					        let mut res = x.clone();
 | 
				
			||||||
 | 
					        b.iter(|| operators::SBP4.diffeta(x.view(), res.view_mut()))
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					    group.bench_function("trad8 diffeta", |b| {
 | 
				
			||||||
 | 
					        let mut res = x.clone();
 | 
				
			||||||
 | 
					        b.iter(|| operators::SBP8.diffeta(x.view(), res.view_mut()))
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    group.finish();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					criterion_group!(benches, performance_benchmark);
 | 
				
			||||||
 | 
					criterion_main!(benches);
 | 
				
			||||||
		Reference in New Issue
	
	Block a user