⬆️ rand

This commit is contained in:
Aleksey Kladov 2019-07-02 14:40:43 +03:00
parent 636e48d45d
commit 89237e85f7
3 changed files with 8 additions and 4 deletions

View file

@ -17,10 +17,12 @@ log = "0.4.5"
parking_lot = "0.8.0"
rustc-hash = "1.0"
smallvec = "0.6.5"
rand = { version = "0.7", features = [ "small_rng" ] }
salsa-macros = { version = "0.13.0", path = "components/salsa-macros" }
rand = "0.6"
[dev-dependencies]
rand_distr = "0.2.1"
diff = "0.1.0"
env_logger = "0.5.13"
linked-hash-map = "0.5.2"

View file

@ -2,7 +2,7 @@
use super::*;
use linked_hash_map::LinkedHashMap;
use rand::distributions::{Distribution, Normal};
use rand_distr::{Distribution, Normal};
#[derive(Debug)]
struct TestNode {
@ -56,7 +56,7 @@ fn compare(
let mut lru_hits = 0;
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) {
let request_id = (normal.sample(&mut pick_rng) as usize).min(num_nodes - 1);
assert!(request_id < num_nodes);

View file

@ -1,4 +1,6 @@
use rand::seq::SliceRandom;
use rand::Rng;
use salsa::Database;
use salsa::ParallelDatabase;
use salsa::Snapshot;
@ -82,7 +84,7 @@ enum ReadOp {
impl rand::distributions::Distribution<Query> for rand::distributions::Standard {
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()
}
}