// Copyright (C) 2022 Laurent Wandrebeck // // This file is part of ripeg. // // ripeg is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // ripeg is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with ripeg. If not, see . use criterion::{criterion_group, criterion_main, Criterion}; use ripeg::isa::*; fn program_new() { let _p = Program::new(); } fn program_size() { let p = Program::new(); // call p.size() several times to negate new() call time. let mut _s = p.size(); let mut _s = p.size(); let mut _s = p.size(); let mut _s = p.size(); let mut _s = p.size(); let mut _s = p.size(); let mut _s = p.size(); let mut _s = p.size(); } fn program_new_benchmark(c: &mut Criterion) { c.bench_function("program_new", |b| b.iter(|| program_new())); } fn program_size_benchmark(c: &mut Criterion) { c.bench_function("program_size", |b| b.iter(|| program_size())); } criterion_group!( benches, program_new_benchmark, program_size_benchmark, ); criterion_main!(benches);