Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
pitdicker committed Dec 17, 2017
1 parent 2448e21 commit 25dfbdd
Show file tree
Hide file tree
Showing 6 changed files with 417 additions and 162 deletions.
10 changes: 5 additions & 5 deletions benches/generators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use test::{black_box, Bencher};

use rand::{Rng, NewSeeded, Sample, SeedFromRng, StdRng, OsRng, JitterRng, thread_rng};
use rand::prng::*;
use rand::reseeding::{ReseedingRng, ReseedWithNew};
//use rand::reseeding::{ReseedingRng, ReseedWithNew};

macro_rules! gen_bytes {
($fnn:ident, $gen:ident) => {
Expand Down Expand Up @@ -105,7 +105,7 @@ fn init_jitter(b: &mut Bencher) {
}



/*
#[bench]
fn reseeding_xorshift_bytes(b: &mut Bencher) {
let mut rng = ReseedingRng::new(XorShiftRng::new().unwrap(),
Expand Down Expand Up @@ -140,9 +140,9 @@ macro_rules! reseeding_uint {
reseeding_uint!(reseeding_xorshift_u32, u32);
reseeding_uint!(reseeding_xorshift_u64, u64);
*/



/*
#[bench]
fn gen_bytes_threadrng(b: &mut Bencher) {
let mut rng = thread_rng();
Expand All @@ -155,7 +155,7 @@ fn gen_bytes_threadrng(b: &mut Bencher) {
});
b.bytes = BYTES_LEN as u64 * RAND_BENCH_N;
}

*/
macro_rules! reseeding_uint {
($fnn:ident, $ty:ty) => {
#[bench]
Expand Down
8 changes: 8 additions & 0 deletions rand_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,14 @@ pub trait Rng {
/// implemented for well-reviewed code implementing well-regarded algorithms.
pub trait CryptoRng: Rng {}

/// FIXME
pub trait RngCore: Sized {
type Results: AsRef<[u32]>;

fn init(seed: &[u32]) -> Self;
fn generate(&mut self, results: &mut Self::Results);
fn results_empty() -> Self::Results;
}

impl<'a, R: Rng+?Sized> Rng for &'a mut R {
fn next_u32(&mut self) -> u32 {
Expand Down
Loading

0 comments on commit 25dfbdd

Please sign in to comment.