Compare commits
2 Commits
7185e91cc4
...
d8153408e1
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d8153408e1 | ||
![]() |
e87d6b7398 |
@ -1,10 +1,12 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "rusttest"
|
name = "rusttest"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# add https://github.com/Magnus167/rustframe as a dependency
|
# add https://github.com/Magnus167/rustframe as a dependency
|
||||||
rustframe = { git = "https://github.com/Magnus167/rustframe.git" , rev = "refs/pull/19/head" }
|
# rustframe = { git = "https://github.com/Magnus167/rustframe.git" , rev = "refs/pull/19/head" }
|
||||||
|
rustframe = { git = "https://gitea.nulltech.uk/Magnus167/rustframe.git" , branch = "matr_eq" }
|
||||||
|
|
||||||
chrono = { version = "*" }
|
chrono = { version = "*" }
|
||||||
rand = { version = "*" }
|
rand = { version = "*" }
|
17
src/main.rs
17
src/main.rs
@ -1,6 +1,5 @@
|
|||||||
use chrono::NaiveDate;
|
use chrono::NaiveDate;
|
||||||
use rand::distr::Uniform;
|
use rand::Rng; // Import thread_rng for random number generation
|
||||||
use rand::{Rng, rng}; // Import thread_rng for random number generation
|
|
||||||
use rustframe::frame::{Frame, RowIndex};
|
use rustframe::frame::{Frame, RowIndex};
|
||||||
use rustframe::matrix::{BoolMatrix, BoolOps, Matrix, SeriesOps}; // Explicitly list used items
|
use rustframe::matrix::{BoolMatrix, BoolOps, Matrix, SeriesOps}; // Explicitly list used items
|
||||||
use rustframe::utils::{BDateFreq, BDatesList};
|
use rustframe::utils::{BDateFreq, BDatesList};
|
||||||
@ -8,8 +7,8 @@ use std::time::Instant; // Use Instant for timing
|
|||||||
|
|
||||||
// Helper function to generate a random f64 between 0.0 and 1.0
|
// Helper function to generate a random f64 between 0.0 and 1.0
|
||||||
fn generate_random_float() -> f64 {
|
fn generate_random_float() -> f64 {
|
||||||
let mut rng = rng(); // Get the thread-local random number generator
|
let mut rng = rand::rng(); // Get the thread-local random number generator
|
||||||
let uniform = Uniform::new(0.0, 1.0).unwrap(); // Define a uniform distribution range and unwrap the result
|
let uniform = rand::distr::Uniform::new(0.0, 1.0).unwrap(); // Define a uniform distribution range and unwrap the result
|
||||||
rng.sample(&uniform) // Sample a value from the distribution
|
rng.sample(&uniform) // Sample a value from the distribution
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,7 +43,7 @@ fn main() {
|
|||||||
|
|
||||||
// --- Configuration ---
|
// --- Configuration ---
|
||||||
let start_date_str = "2000-01-01".to_string();
|
let start_date_str = "2000-01-01".to_string();
|
||||||
let num_periods = 20_000;
|
let num_periods = 1_000;
|
||||||
let num_columns = 1_000;
|
let num_columns = 1_000;
|
||||||
let frequency = BDateFreq::Daily;
|
let frequency = BDateFreq::Daily;
|
||||||
|
|
||||||
@ -129,14 +128,10 @@ fn main() {
|
|||||||
|
|
||||||
// Complex operation
|
// Complex operation
|
||||||
let complex_start_time = Instant::now();
|
let complex_start_time = Instant::now();
|
||||||
let frame_r = &frame_a * &frame_b;
|
let frame_r = &(&(&(&(&frame_a * &frame_b) / &frame_b) - &frame_a) + &frame_a) - &frame_a;
|
||||||
let frame_r = &frame_r / &frame_b;
|
|
||||||
let frame_r = &frame_r - &frame_a;
|
|
||||||
let frame_r = &frame_r + &frame_a;
|
|
||||||
let frame_r = &frame_r - &frame_a;
|
|
||||||
|
|
||||||
let frame_r = frame_r.matrix().lt_elementwise(0.0000001);
|
let frame_r = frame_r.matrix().lt_elementwise(0.0000001);
|
||||||
let complex_result = frame_r.any();
|
let complex_result = frame_r.all();
|
||||||
let complex_duration = complex_start_time.elapsed();
|
let complex_duration = complex_start_time.elapsed();
|
||||||
println!("Complex operation duration: {:?}", complex_duration);
|
println!("Complex operation duration: {:?}", complex_duration);
|
||||||
println!(
|
println!(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user