make range benchmark have random distributed points
This commit is contained in:
parent
0a54cad11e
commit
36ffce22f9
2 changed files with 14 additions and 1 deletions
|
|
@ -3,6 +3,7 @@ use std::hint::black_box;
|
||||||
use autobarts::{geom::Point, spindex::RStarTree};
|
use autobarts::{geom::Point, spindex::RStarTree};
|
||||||
use bevy::math::Vec2;
|
use bevy::math::Vec2;
|
||||||
use criterion::{Criterion, criterion_group};
|
use criterion::{Criterion, criterion_group};
|
||||||
|
use rand::{Rng, SeedableRng, seq::SliceRandom};
|
||||||
|
|
||||||
//
|
//
|
||||||
// Benchmark Parameters
|
// Benchmark Parameters
|
||||||
|
|
@ -11,6 +12,8 @@ pub const BENCH_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(10
|
||||||
pub const BENCH_NUM_INSERT: i32 = 50_000;
|
pub const BENCH_NUM_INSERT: i32 = 50_000;
|
||||||
pub const BENCH_NODE_CAPACITY: usize = 5;
|
pub const BENCH_NODE_CAPACITY: usize = 5;
|
||||||
|
|
||||||
|
const SEED: u64 = 8;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Data Generation Functions (Raw Data)
|
// Data Generation Functions (Raw Data)
|
||||||
//
|
//
|
||||||
|
|
@ -39,7 +42,14 @@ pub fn configure_criterion() -> Criterion {
|
||||||
const BENCH_RANGE_RADIUS: f32 = 30.0;
|
const BENCH_RANGE_RADIUS: f32 = 30.0;
|
||||||
|
|
||||||
fn benchmark_range_rstartree_2d(_c: &mut Criterion) {
|
fn benchmark_range_rstartree_2d(_c: &mut Criterion) {
|
||||||
let points = generate_2d_data();
|
let mut points = generate_2d_data();
|
||||||
|
let mut rng = rand::rngs::StdRng::seed_from_u64(SEED);
|
||||||
|
let len = points.len();
|
||||||
|
for i in 0..len {
|
||||||
|
let j = rng.random_range(0..len);
|
||||||
|
points.swap(i, j);
|
||||||
|
}
|
||||||
|
|
||||||
let mut tree = RStarTree::new(BENCH_NODE_CAPACITY);
|
let mut tree = RStarTree::new(BENCH_NODE_CAPACITY);
|
||||||
|
|
||||||
tree.insert_bulk(points.clone());
|
tree.insert_bulk(points.clone());
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
|
// based on code stolen under the terms of the MIT license from
|
||||||
|
// https://github.com/habedi/spart/blob/0f0e92c556b8906801d3f8b9c2a8a6491f493d9c/src/rstar_tree.rs
|
||||||
|
|
||||||
use bevy::{
|
use bevy::{
|
||||||
math::bounding::{Aabb2d, BoundingVolume, IntersectsVolume},
|
math::bounding::{Aabb2d, BoundingVolume, IntersectsVolume},
|
||||||
prelude::Vec2,
|
prelude::Vec2,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue