make range benchmark have random distributed points

This commit is contained in:
joe 2026-01-22 20:47:10 -08:00
parent 0a54cad11e
commit 36ffce22f9
2 changed files with 14 additions and 1 deletions

View file

@ -3,6 +3,7 @@ use std::hint::black_box;
use autobarts::{geom::Point, spindex::RStarTree};
use bevy::math::Vec2;
use criterion::{Criterion, criterion_group};
use rand::{Rng, SeedableRng, seq::SliceRandom};
//
// 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_NODE_CAPACITY: usize = 5;
const SEED: u64 = 8;
//
// Data Generation Functions (Raw Data)
//
@ -39,7 +42,14 @@ pub fn configure_criterion() -> Criterion {
const BENCH_RANGE_RADIUS: f32 = 30.0;
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);
tree.insert_bulk(points.clone());

View file

@ -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::{
math::bounding::{Aabb2d, BoundingVolume, IntersectsVolume},
prelude::Vec2,