final timings and logs done
finished the readme tweaked a few other things
This commit is contained in:
parent
1709084904
commit
ef279ae4f4
6 changed files with 5816 additions and 7 deletions
4707
1_billion.log
Normal file
4707
1_billion.log
Normal file
File diff suppressed because it is too large
Load diff
1067
1_billion_with_multithread_rand.log
Normal file
1067
1_billion_with_multithread_rand.log
Normal file
File diff suppressed because it is too large
Load diff
11
1_milion.log
Normal file
11
1_milion.log
Normal file
|
@ -0,0 +1,11 @@
|
|||
HIGH_SCORE: 0
|
||||
ROLL_COUNT: 0
|
||||
HIGH_SCORE: 92
|
||||
ROLL_COUNT: 423264
|
||||
HIGH_SCORE: 92
|
||||
ROLL_COUNT: 856018
|
||||
HIGH_SCORE: 92
|
||||
ROLL_COUNT: 1000000
|
||||
HIGH_SCORE: 92
|
||||
ROLL_COUNT: 1000000
|
||||
realtime 0:04.40
|
7
1_milion_with_multithread_rand.log
Normal file
7
1_milion_with_multithread_rand.log
Normal file
|
@ -0,0 +1,7 @@
|
|||
HIGH_SCORE: 74
|
||||
ROLL_COUNT: 337
|
||||
HIGH_SCORE: 91
|
||||
ROLL_COUNT: 1000000
|
||||
HIGH_SCORE: 91
|
||||
ROLL_COUNT: 1000000
|
||||
realtime 0:01.00
|
19
README.md
19
README.md
|
@ -1,3 +1,20 @@
|
|||
# graveler-softlockpicking-years-wasted-calculator
|
||||
|
||||
This repo is a short and sweet response to Austins most recent video 'The Science of Soft Lock Picking Pokemon' available here https://www.youtube.com/watch?v=M8C8dHQE2Ro
|
||||
This repo is a short and sweet response to Austins most recent video 'The Science of Soft Lock Picking Pokemon' available here https://www.youtube.com/watch?v=M8C8dHQE2Ro
|
||||
|
||||
## Programs
|
||||
[`time`](https://www.gnu.org/software/time/) to record execution time
|
||||
|
||||
[`rustup`](https://rustup.rs/) to install cargo, and all other tools used by the rust ecosystem
|
||||
|
||||
[`cargo`](https://github.com/rust-lang/cargo) to compile the program
|
||||
|
||||
# Timings
|
||||
|
||||
### 1 billion
|
||||
comparable to the python implementation: 39:12.67
|
||||
multithreading and a better random library: 8:51.31
|
||||
|
||||
### 1 million
|
||||
comparable to the python implementation: 0:04.40
|
||||
multithreading and a better random library: 0:01.00
|
12
src/main.rs
12
src/main.rs
|
@ -4,8 +4,8 @@ use std::{
|
|||
time::Duration,
|
||||
};
|
||||
|
||||
//const ITER_COUNT: usize = 1_000_000_000;
|
||||
const ITER_COUNT: usize = 1_000_000;
|
||||
const ITER_COUNT: usize = 1_000_000_000;
|
||||
//const ITER_COUNT: usize = 1_000_000;
|
||||
|
||||
static THREAD_STOP: AtomicBool = AtomicBool::new(false);
|
||||
static ROLL_COUNT: AtomicUsize = AtomicUsize::new(0);
|
||||
|
@ -34,7 +34,7 @@ fn main() {
|
|||
#[cfg(feature = "auto_thread_count")]
|
||||
let thread_count: usize = num_cpus::get();
|
||||
#[cfg(not(feature = "auto_thread_count"))]
|
||||
let thread_count: usize = 4; // Change me to any number you want to use as the thread count, please note you must not be using the 'auto_thread_count' feature, see README.md for details
|
||||
let thread_count: usize = 1; // Change me to any number you want to use as the thread count, please note you must not be using the 'auto_thread_count' feature, see README.md for details
|
||||
|
||||
// divide the total iter count among multiple threads
|
||||
let thread_dispatch = {
|
||||
|
@ -63,7 +63,8 @@ fn main() {
|
|||
}
|
||||
|
||||
loop {
|
||||
println!("{}", HIGH_SCORE.load(Ordering::SeqCst));
|
||||
println!("HIGH_SCORE: {}", HIGH_SCORE.load(Ordering::SeqCst));
|
||||
println!("ROLL_COUNT: {}", ROLL_COUNT.load(Ordering::SeqCst));
|
||||
|
||||
// if all threads are done break the loop
|
||||
{
|
||||
|
@ -81,8 +82,8 @@ fn main() {
|
|||
thread::sleep(Duration::from_secs(1));
|
||||
}
|
||||
|
||||
println!("ROLL_COUNT: {}", ROLL_COUNT.load(Ordering::SeqCst));
|
||||
println!("HIGH_SCORE: {}", HIGH_SCORE.load(Ordering::SeqCst));
|
||||
println!("ROLL_COUNT: {}", ROLL_COUNT.load(Ordering::SeqCst));
|
||||
}
|
||||
|
||||
fn number_cruncher(iter_count: usize) {
|
||||
|
@ -97,7 +98,6 @@ fn number_cruncher(iter_count: usize) {
|
|||
|
||||
// turns
|
||||
for _ in 0..231 {
|
||||
// TODO compare this with a random usize % 4, or the classic (SEED^3)%4 trick
|
||||
#[cfg(feature = "rust_random")]
|
||||
let rand = rand::Rng::gen_range(&mut rand::thread_rng(), 0..4);
|
||||
#[cfg(not(feature = "rust_random"))]
|
||||
|
|
Loading…
Add table
Reference in a new issue