Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use criterion::{black_box, criterion_group, criterion_main, Criterion};
- pub fn rc(c: &mut Criterion) {
- use std::rc::Rc;
- let rc = Rc::new(64);
- c.bench_function("rc", |b| b.iter(|| (black_box(rc.clone()))));
- }
- pub fn arc(c: &mut Criterion) {
- use std::sync::Arc;
- let arc = Arc::new(64);
- c.bench_function("arc", |b| b.iter(|| (black_box(arc.clone()))));
- }
- pub fn arr(c: &mut Criterion) {
- let arr = [0_u8; 1024];
- c.bench_function("arr", |b| b.iter(|| (black_box(arr.clone()))));
- }
- pub fn bstr(c: &mut Criterion) {
- let bstr: Box<str> = black_box(black_box("Hi").into());
- c.bench_function("bstr", |b| b.iter(|| (black_box(bstr.clone()))));
- }
- criterion_group!(benches, rc, arc, arr, bstr);
- criterion_main!(benches);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement