-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
171 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
use codspeed_criterion_compat::{black_box, criterion_group, criterion_main, Criterion}; | ||
use ndarray::{arr2, Array2}; | ||
use powerboxesrs::giou::{giou_distance, parallel_giou_distance}; | ||
use powerboxesrs::iou::{iou_distance, parallel_iou_distance}; | ||
|
||
pub fn iou_distance_benchmark(c: &mut Criterion) { | ||
let mut boxes1 = Array2::<f64>::zeros((100, 4)); | ||
for i in 0..100 { | ||
for j in 0..4 { | ||
if j < 2 { | ||
boxes1[[i, j]] = 0.0; | ||
} else { | ||
boxes1[[i, j]] = 10.0; | ||
} | ||
} | ||
} | ||
let boxes2 = boxes1.clone(); | ||
|
||
c.bench_function("iou distance benchmark", |b| { | ||
b.iter(|| iou_distance(black_box(&boxes1), black_box(&boxes2))) | ||
}); | ||
} | ||
|
||
pub fn parallel_iou_distance_benchmark(c: &mut Criterion) { | ||
let mut boxes1 = Array2::<f64>::zeros((100, 4)); | ||
for i in 0..100 { | ||
for j in 0..4 { | ||
if j < 2 { | ||
boxes1[[i, j]] = 0.0; | ||
} else { | ||
boxes1[[i, j]] = 10.0; | ||
} | ||
} | ||
} | ||
let boxes2 = boxes1.clone(); | ||
|
||
c.bench_function("parallel iou distance benchmark", |b| { | ||
b.iter(|| parallel_iou_distance(black_box(&boxes1), black_box(&boxes2))) | ||
}); | ||
} | ||
|
||
pub fn giou_distance_benchmark(c: &mut Criterion) { | ||
let mut boxes1 = Array2::<f64>::zeros((100, 4)); | ||
for i in 0..100 { | ||
for j in 0..4 { | ||
if j < 2 { | ||
boxes1[[i, j]] = 0.0; | ||
} else { | ||
boxes1[[i, j]] = 10.0; | ||
} | ||
} | ||
} | ||
let boxes2 = boxes1.clone(); | ||
|
||
c.bench_function("giou distance benchmark", |b| { | ||
b.iter(|| giou_distance(black_box(&boxes1), black_box(&boxes2))) | ||
}); | ||
} | ||
|
||
pub fn parallel_giou_distance_benchmark(c: &mut Criterion) { | ||
let mut boxes1 = Array2::<f64>::zeros((100, 4)); | ||
for i in 0..100 { | ||
for j in 0..4 { | ||
if j < 2 { | ||
boxes1[[i, j]] = 0.0; | ||
} else { | ||
boxes1[[i, j]] = 10.0; | ||
} | ||
} | ||
} | ||
let boxes2 = boxes1.clone(); | ||
|
||
c.bench_function("parallel giou distance benchmark", |b| { | ||
b.iter(|| parallel_giou_distance(black_box(&boxes1), black_box(&boxes2))) | ||
}); | ||
} | ||
|
||
criterion_group!( | ||
benches, | ||
iou_distance_benchmark, | ||
parallel_iou_distance_benchmark, | ||
giou_distance_benchmark, | ||
parallel_giou_distance_benchmark | ||
); | ||
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters