rename to spacedog, remove unneccessary atomics

This commit is contained in:
Joe 2025-10-17 11:59:14 -07:00
parent 4ca8e55dab
commit eb1efaf694
2 changed files with 11 additions and 16 deletions

View file

@ -1,14 +1,13 @@
[package]
name = "spacebench"
name = "spacedog"
version = "0.1.0"
edition = "2024"
[dependencies]
[dev-dependencies]
clap = "4.5.49"
criterion = "0.7.0"
rand = "0.9.2"
rand_hc = "0.4.0"
rstar = "0.12.2"
[[bench]]
name = "benchmarks"

View file

@ -11,15 +11,15 @@ struct Point2d {
y: f64,
}
#[derive(Debug, Default)]
#[derive(Debug, Default, Clone, Copy)]
struct PVal {
point: usize,
val: AtomicU64,
val: f64,
}
impl PartialEq for PVal {
fn eq(&self, other: &Self) -> bool {
self.val.load(Relaxed) == other.val.load(Relaxed)
self.val == other.val
}
}
@ -27,15 +27,13 @@ impl Eq for PVal {}
impl PartialOrd for PVal {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
let a = f64::from_bits(self.val.load(Relaxed));
let b = f64::from_bits(other.val.load(Relaxed));
a.partial_cmp(&b)
Some(self.cmp(other))
}
}
impl Ord for PVal {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.partial_cmp(other).unwrap()
self.val.partial_cmp(&other.val).unwrap()
}
}
@ -55,12 +53,12 @@ impl Spindex2d {
for (i, point) in points.iter().enumerate() {
let x = PVal {
point: i,
val: AtomicU64::new(point.x.to_bits()),
val: point.x,
};
xs.push(x);
let y = PVal {
point: i,
val: AtomicU64::new(point.y.to_bits()),
val: point.y,
};
ys.push(y);
@ -89,17 +87,15 @@ impl Spindex2d {
for (i, point) in points.iter().enumerate() {
let xi = self.xpoints[i].load(Relaxed);
let yi = self.ypoints[i].load(Relaxed);
let x = point.x.to_bits();
let x = PVal {
point: i,
val: x.into(),
val: point.x,
};
xs[xi] = x;
let y = point.y.to_bits();
let y = PVal {
point: i,
val: y.into(),
val: point.y,
};
ys[yi] = y;
}