// [[file:../elastic.note::021b3094][021b3094]] use gchemol::prelude::*; use gchemol::Molecule; use gut::prelude::*; use std::collections::{HashMap, HashSet}; use criterion::{black_box, criterion_group, criterion_main, Criterion}; use gosh_elastic::*; type Array3 = [f64; 3]; type Positions = Vec; fn init() -> Result<(Positions, Positions)> { let f = "./tests/files/opt-traj-large.xyz"; let mols = gchemol::io::read(f)?.collect_vec(); let positions1 = mols[0].positions().collect_vec(); let positions2 = mols[1].positions().collect_vec(); Ok((positions1, positions2)) } fn trajectory(positions1: &[Array3], positions2: &[Array3]) { direct::compute_elastic_energy_and_force_distance_space(positions1, positions2); // elastic::compute_elastic_energy_and_force_distance_space(positions1, positions2); } fn criterion_benchmark(c: &mut Criterion) { let (positions1, positions2) = init().unwrap(); c.bench_function("trajectory", |b| { b.iter(|| black_box(trajectory(&positions1, &positions2))) }); } criterion_group!(benches, criterion_benchmark); criterion_main!(benches); // 021b3094 ends here