mirror of
https://github.com/Noratrieb/brainfuck.git
synced 2026-01-14 21:35:02 +01:00
doc comments and further testing
This commit is contained in:
parent
5b9dd9ca67
commit
248d07e317
5 changed files with 727 additions and 164 deletions
|
|
@ -1,7 +1,10 @@
|
|||
//!
|
||||
//! The very basic interpreter without any optimizations
|
||||
|
||||
use crate::interpreter::{MEM_SIZE, minify};
|
||||
use std::io::{stdin, Read};
|
||||
|
||||
pub fn run(program: &str) -> String{
|
||||
pub fn _run(program: &str) -> String{
|
||||
let program = minify(program);
|
||||
let out = interpret(program.chars().collect());
|
||||
out
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
/*!
|
||||
# optimization time
|
||||
|
||||
first parse the bf so that it can be executed faster
|
||||
most importantly: loop jumps should be immediate
|
||||
*/
|
||||
|
||||
//!
|
||||
//! # optimization time
|
||||
//!
|
||||
//! first parse the bf so that it can be executed faster
|
||||
//! most importantly: loop jumps should be immediate
|
||||
//!
|
||||
use std::io::{Read, stdin};
|
||||
|
||||
use crate::interpreter::{MEM_SIZE, Memory, minify, parse, Statement};
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
/*!
|
||||
# optimization time
|
||||
some better optimizations like set null, repeating and doing more stuff with simplifying stuff
|
||||
*/
|
||||
//! # optimization time
|
||||
//! some better optimizations like set null, repeating and doing more stuff with simplifying stuff
|
||||
//!
|
||||
|
||||
use std::io::{Read, stdin};
|
||||
|
||||
|
|
|
|||
|
|
@ -20,16 +20,13 @@ fn main() {
|
|||
fn run(path: String) {
|
||||
println!("Path: {}", path);
|
||||
let program = fs::read_to_string(path).unwrap();
|
||||
let start0 = SystemTime::now();
|
||||
let out0 = interpreter::o0::run(&*program);
|
||||
let end0 = start0.elapsed().unwrap();
|
||||
let start1 = SystemTime::now();
|
||||
|
||||
/* let start1 = SystemTime::now();
|
||||
let out = interpreter::o1::run(&*program);
|
||||
let end1 = start1.elapsed().unwrap();
|
||||
let end1 = start1.elapsed().unwrap();*/
|
||||
let start2 = SystemTime::now();
|
||||
let out2 = interpreter::o2::run(&*program).unwrap();
|
||||
let end2 = start2.elapsed().unwrap();
|
||||
assert_eq!(out, out2);
|
||||
assert_eq!(out0, out2);
|
||||
println!("{}\nFinished execution. Took o0: {}ms, o1: {}ms, o2: {}ms", out, end0.as_millis(), end1.as_millis(), end2.as_millis());
|
||||
//assert_eq!(out, out2);
|
||||
println!("{}\nFinished execution. Took o1: 18008ms (for hanoi), o2: {}ms", out2/*, end1.as_millis()*/, end2.as_millis());
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue