Implementation of the UM-32 "Universal Machine" as described by the Cult of the Bound Variable

add timing feature

tjh 61d725d1 890c4632

+9
+1
Cargo.toml
··· 10 default = ["reclaim-memory"] 11 reclaim-memory = [] 12 smallvec = ["dep:smallvec"]
··· 10 default = ["reclaim-memory"] 11 reclaim-memory = [] 12 smallvec = ["dep:smallvec"] 13 + timing = []
+8
src/main.rs
··· 1 #[cfg(feature = "smallvec")] 2 use smallvec::SmallVec; 3 use std::time::Instant; 4 5 #[cfg(feature = "smallvec")] ··· 178 179 /// Begins the spin-cycle of the universal machine. 180 pub fn run(mut self) { 181 loop { 182 match self.ops[self.program_counter as usize] { 183 // Operator #0. Conditional Move. ··· 357 358 self.program_counter += 1; 359 } 360 } 361 362 /// Loads the value from the specified register. ··· 419 } 420 } 421 422 #[inline(never)] 423 fn panic(&self) -> ! { 424 panic!(
··· 1 #[cfg(feature = "smallvec")] 2 use smallvec::SmallVec; 3 + #[cfg(feature = "timing")] 4 use std::time::Instant; 5 6 #[cfg(feature = "smallvec")] ··· 179 180 /// Begins the spin-cycle of the universal machine. 181 pub fn run(mut self) { 182 + #[cfg(feature = "timing")] 183 + let start = Instant::now(); 184 + 185 loop { 186 match self.ops[self.program_counter as usize] { 187 // Operator #0. Conditional Move. ··· 361 362 self.program_counter += 1; 363 } 364 + 365 + #[cfg(feature = "timing")] 366 + eprintln!("um complete: {:?}", start.elapsed()); 367 } 368 369 /// Loads the value from the specified register. ··· 426 } 427 } 428 429 + #[cold] 430 #[inline(never)] 431 fn panic(&self) -> ! { 432 panic!(