Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move the benchmarks to Criterion #507

Merged
merged 2 commits into from
Aug 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pkg-config = "0.3.12"
bindgen = { version = "0.37", optional = true }

[dev-dependencies]
bencher = "0.1.5"
criterion = "0.2"

[[bin]]
name = "rav1e"
Expand Down
43 changes: 10 additions & 33 deletions benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
// PATENTS file, you can obtain it at www.aomedia.org/license/patent.

#[macro_use]
extern crate bencher;
extern crate criterion;
extern crate rand;
extern crate rav1e;

mod predict;

use bencher::*;
use criterion::*;
use rav1e::*;
use rav1e::context::*;
use rav1e::ec;
Expand All @@ -24,31 +24,13 @@ use rav1e::predict::*;
#[cfg(feature = "comparative_bench")]
mod comparative;

struct WriteB {
tx_size: TxSize,
qi: usize
}

impl TDynBenchFn for WriteB {
fn run(&self, b: &mut Bencher) {
write_b_bench(b, self.tx_size, self.qi);
}
}

pub fn write_b() -> Vec<TestDescAndFn> {
use std::borrow::Cow;
let mut benches = ::std::vec::Vec::new();
fn write_b(c: &mut Criterion) {
for &tx_size in &[TxSize::TX_4X4, TxSize::TX_8X8] {
for &qi in &[20, 55] {
let w = WriteB { tx_size, qi };
let n = format!("write_b_bench({:?}, {})", tx_size, qi);
benches.push(TestDescAndFn {
desc: TestDesc { name: Cow::from(n), ignore: false },
testfn: TestFn::DynBenchFn(Box::new(w))
});
c.bench_function(&n, move |b| write_b_bench(b, tx_size, qi));
}
}
benches
}

fn write_b_bench(b: &mut Bencher, tx_size: TxSize, qindex: usize) {
Expand Down Expand Up @@ -108,20 +90,15 @@ fn write_b_bench(b: &mut Bencher, tx_size: TxSize, qindex: usize) {
});
}

benchmark_group!(
criterion_group!(
intra_prediction,
predict::intra_dc_4x4,
predict::intra_h_4x4,
predict::intra_v_4x4,
predict::intra_paeth_4x4,
predict::intra_smooth_4x4,
predict::intra_smooth_h_4x4,
predict::intra_smooth_v_4x4,
predict::intra_cfl_4x4
predict::pred_bench,
);

criterion_group!(write_block, write_b);

#[cfg(feature = "comparative_bench")]
benchmark_main!(comparative::intra_prediction);
criterion_main!(comparative::intra_prediction);

#[cfg(not(feature = "comparative_bench"))]
benchmark_main!(write_b, intra_prediction);
criterion_main!(write_block, intra_prediction);
51 changes: 19 additions & 32 deletions benches/comparative/mod.rs
Original file line number Diff line number Diff line change
@@ -1,32 +1,19 @@
// Copyright (c) 2017-2018, The rav1e contributors. All rights reserved
//
// This source code is subject to the terms of the BSD 2 Clause License and
// the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
// was not distributed with this source code in the LICENSE file, you can
// obtain it at www.aomedia.org/license/software. If the Alliance for Open
// Media Patent License 1.0 was not distributed with this source code in the
// PATENTS file, you can obtain it at www.aomedia.org/license/patent.

extern crate libc;

mod predict;

benchmark_group!(
intra_prediction,
predict::intra_dc_4x4_native,
predict::intra_dc_4x4_aom,
predict::intra_h_4x4_native,
predict::intra_h_4x4_aom,
predict::intra_v_4x4_native,
predict::intra_v_4x4_aom,
predict::intra_paeth_4x4_native,
predict::intra_paeth_4x4_aom,
predict::intra_smooth_4x4_native,
predict::intra_smooth_4x4_aom,
predict::intra_smooth_h_4x4_native,
predict::intra_smooth_h_4x4_aom,
predict::intra_smooth_v_4x4_native,
predict::intra_smooth_v_4x4_aom,
predict::intra_cfl_4x4_native,
predict::intra_cfl_4x4_aom
);
// Copyright (c) 2017-2018, The rav1e contributors. All rights reserved
//
// This source code is subject to the terms of the BSD 2 Clause License and
// the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
// was not distributed with this source code in the LICENSE file, you can
// obtain it at www.aomedia.org/license/software. If the Alliance for Open
// Media Patent License 1.0 was not distributed with this source code in the
// PATENTS file, you can obtain it at www.aomedia.org/license/patent.

extern crate libc;

mod predict;

use criterion::Criterion;

criterion_group!(
intra_prediction,
predict::intra_bench,
);
Loading