Skip to content

Commit

Permalink
feat: update test result
Browse files Browse the repository at this point in the history
  • Loading branch information
dancixx committed Jan 5, 2025
1 parent 852e65f commit 292e5ba
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions src/stochastic/noise/fgn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ impl Sampling<f64> for FGN {

#[cfg(test)]
mod tests {
use std::time::Instant;

use prettytable::{Cell, Row, Table};

use crate::{plot_1d, stochastic::N};

use super::*;
Expand All @@ -114,19 +118,34 @@ mod tests {

#[test]
fn fgn_speed_test() {
let start = std::time::Instant::now();
let mut table = Table::new();

table.add_row(Row::new(vec![
Cell::new("Test Case"),
Cell::new("Elapsed Time (ms)"),
]));

let start = Instant::now();
let fbm = FGN::new(0.7, N, Some(1.0), None);
let _ = fbm.sample();
let duration = start.elapsed();
println!("Time elapsed in sample() is: {:?}", duration);
table.add_row(Row::new(vec![
Cell::new("Single Sample"),
Cell::new(&format!("{:.2?}", duration.as_millis())),
]));

let start = std::time::Instant::now();
let start = Instant::now();
let fbm = FGN::new(0.7, N, Some(1.0), None);
for _ in 0..N {
let _ = fbm.sample();
}
let duration = start.elapsed();
println!("Time elapsed in sample() is: {:?}", duration);
table.add_row(Row::new(vec![
Cell::new("Repeated Samples"),
Cell::new(&format!("{:.2?}", duration.as_millis())),
]));

table.printstd();
}

#[test]
Expand Down

0 comments on commit 292e5ba

Please sign in to comment.