From 82be155886222222f3e1fb2edeea04e57fcd4ec6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Ko=C5=82aczkowski?= Date: Wed, 7 Aug 2024 10:24:04 +0200 Subject: [PATCH] Use faster RNG --- Cargo.toml | 2 +- src/workload.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d8b2736..660c498 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,7 +34,7 @@ openssl = "0.10.38" parse_duration = "2.1.1" pin-project = "1.1" plotters = { version = "0.3", default-features = false, features = ["line_series", "svg_backend", "full_palette"]} -rand = "0.8" +rand = { version = "0.8", default-features = false, features = ["small_rng", "std"] } regex = "1.5" rune = "0.13" rust-embed = "8" diff --git a/src/workload.rs b/src/workload.rs index 8f53d93..c69a2db 100644 --- a/src/workload.rs +++ b/src/workload.rs @@ -7,7 +7,7 @@ use std::time::Instant; use hdrhistogram::Histogram; use rand::distributions::{Distribution, WeightedIndex}; -use rand::rngs::StdRng; +use rand::rngs::SmallRng; use rand::{Rng, SeedableRng}; use rune::alloc::clone::TryClone; use rune::compile::meta::Kind; @@ -452,7 +452,7 @@ impl Workload { /// Returns the cycle number and the end time of the query. pub async fn run(&self, cycle: i64) -> Result<(i64, Instant), LatteError> { let start_time = Instant::now(); - let mut rng = StdRng::seed_from_u64(cycle as u64); + let mut rng = SmallRng::seed_from_u64(cycle as u64); let context = SessionRef::new(&self.context); let result = self .program