#![feature(test)]
extern crate test;
use test::Bencher;
use randomize::*;
use std::time::{SystemTime, UNIX_EPOCH};
pub fn u64_from_time() -> u64 {
let unix_delta = match SystemTime::now().duration_since(UNIX_EPOCH) {
Ok(duration) => duration,
Err(system_time_error) => system_time_error.duration(),
};
if unix_delta.subsec_nanos() != 0 {
unix_delta.as_secs().wrapping_mul(unix_delta.subsec_nanos() as u64)
} else {
unix_delta.as_secs()
}
}
#[bench]
fn bench_xsl_rr_64_32(b: &mut Bencher) {
let mut state = u64_from_time();
b.iter(|| state = xsl_rr_64_32(state) as u64);
}
#[bench]
fn bench_xsl_rr_128_64(b: &mut Bencher) {
let mut state = ((u64_from_time() as u128) << 64) | (u64_from_time() as u128);
b.iter(|| state = xsl_rr_128_64(state) as u128);
}