mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-01-12 08:30:51 +00:00
commit
76f153e35e
3 changed files with 8 additions and 4 deletions
|
@ -17,10 +17,12 @@ log = "0.4.5"
|
||||||
parking_lot = "0.8.0"
|
parking_lot = "0.8.0"
|
||||||
rustc-hash = "1.0"
|
rustc-hash = "1.0"
|
||||||
smallvec = "0.6.5"
|
smallvec = "0.6.5"
|
||||||
|
rand = { version = "0.7", features = [ "small_rng" ] }
|
||||||
|
|
||||||
salsa-macros = { version = "0.13.0", path = "components/salsa-macros" }
|
salsa-macros = { version = "0.13.0", path = "components/salsa-macros" }
|
||||||
rand = "0.6"
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
rand_distr = "0.2.1"
|
||||||
diff = "0.1.0"
|
diff = "0.1.0"
|
||||||
env_logger = "0.5.13"
|
env_logger = "0.5.13"
|
||||||
linked-hash-map = "0.5.2"
|
linked-hash-map = "0.5.2"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use linked_hash_map::LinkedHashMap;
|
use linked_hash_map::LinkedHashMap;
|
||||||
use rand::distributions::{Distribution, Normal};
|
use rand_distr::{Distribution, Normal};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct TestNode {
|
struct TestNode {
|
||||||
|
@ -56,7 +56,7 @@ fn compare(
|
||||||
let mut lru_hits = 0;
|
let mut lru_hits = 0;
|
||||||
|
|
||||||
let mut pick_rng = super::rng_with_seed(PICK_SEED);
|
let mut pick_rng = super::rng_with_seed(PICK_SEED);
|
||||||
let normal = Normal::new((num_nodes / 2) as f64, standard_deviation as f64);
|
let normal = Normal::new((num_nodes / 2) as f64, standard_deviation as f64).unwrap();
|
||||||
for clock in (0..requests).map(|n| n + 1) {
|
for clock in (0..requests).map(|n| n + 1) {
|
||||||
let request_id = (normal.sample(&mut pick_rng) as usize).min(num_nodes - 1);
|
let request_id = (normal.sample(&mut pick_rng) as usize).min(num_nodes - 1);
|
||||||
assert!(request_id < num_nodes);
|
assert!(request_id < num_nodes);
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
|
use rand::seq::SliceRandom;
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
|
|
||||||
use salsa::Database;
|
use salsa::Database;
|
||||||
use salsa::ParallelDatabase;
|
use salsa::ParallelDatabase;
|
||||||
use salsa::Snapshot;
|
use salsa::Snapshot;
|
||||||
|
@ -82,7 +84,7 @@ enum ReadOp {
|
||||||
|
|
||||||
impl rand::distributions::Distribution<Query> for rand::distributions::Standard {
|
impl rand::distributions::Distribution<Query> for rand::distributions::Standard {
|
||||||
fn sample<R: rand::Rng + ?Sized>(&self, rng: &mut R) -> Query {
|
fn sample<R: rand::Rng + ?Sized>(&self, rng: &mut R) -> Query {
|
||||||
*rng.choose(&[Query::A, Query::B, Query::C]).unwrap()
|
*[Query::A, Query::B, Query::C].choose(rng).unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue