time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

commit dc7bdebd2fec0c8a0f41600eba038142fc36f059
parent 86a5294a551957357b8167f3f7564bedba3b092b
Author: Nuño Sempere <nuno.semperelh@protonmail.com>
Date:   Fri,  5 Apr 2024 23:22:20 +0000

use a simpler & faster prng

Diffstat:
Mrust/Cargo.lock | 1+
Mrust/Cargo.toml | 1+
Mrust/src/.main.rs.swp | 0
Mrust/src/main.rs | 9+++++++--
4 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/rust/Cargo.lock b/rust/Cargo.lock @@ -107,6 +107,7 @@ name = "srust" version = "0.1.0" dependencies = [ "rand", + "rand_core", "rand_distr", "rand_pcg", ] diff --git a/rust/Cargo.toml b/rust/Cargo.toml @@ -7,5 +7,6 @@ edition = "2021" [dependencies] rand = "0.8.5" +rand_core = "0.6.4" rand_distr = "0.4.3" rand_pcg = "0.3.1" diff --git a/rust/src/.main.rs.swp b/rust/src/.main.rs.swp Binary files differ. diff --git a/rust/src/main.rs b/rust/src/main.rs @@ -1,12 +1,17 @@ -use rand::thread_rng; +use rand_core::SeedableRng; +use rand_pcg::Pcg64Mcg; use rand_distr::{Normal, Distribution}; +// use rand::thread_rng; +// use rand::prelude::* + fn main() { println!("Hello, world!"); + let mut rng = Pcg64Mcg::seed_from_u64(1); // mean 2, standard deviation 3 let normal = Normal::new(2.0, 3.0).unwrap(); - let v = normal.sample(&mut thread_rng()); + let v = normal.sample(&mut rng); println!("{} is from a N(2, 9) distribution", v) }