tangled
alpha
login
or
join now
tjh.dev
/
um32
1
fork
atom
Implementation of the UM-32 "Universal Machine" as described by the
Cult of the Bound Variable
1
fork
atom
overview
issues
pulls
pipelines
add timing feature
tjh
1 year ago
61d725d1
890c4632
+9
2 changed files
expand all
collapse all
unified
split
Cargo.toml
src
main.rs
+1
Cargo.toml
···
10
default = ["reclaim-memory"]
11
reclaim-memory = []
12
smallvec = ["dep:smallvec"]
0
···
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;
0
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) {
0
0
0
181
loop {
182
match self.ops[self.program_counter as usize] {
183
// Operator #0. Conditional Move.
···
357
358
self.program_counter += 1;
359
}
0
0
0
360
}
361
362
/// Loads the value from the specified register.
···
419
}
420
}
421
0
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!(