Last active
December 14, 2015 11:09
-
-
Save ehaliewicz/5077506 to your computer and use it in GitHub Desktop.
VM Repl interpreter and compiler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GENLISP> (gen-eval) | |
GEN-Eval: (+ 1 2) | |
;; total-stack-pushes: 6 maximum-stack-depth: 5 | |
;; instructions executed: 86 execution time: 0.05 seconds | |
=> 3 | |
GEN-Eval: (compile (+ 1 2)) | |
;; total-stack-pushes: 0 maximum-stack-depth: 0 | |
;; instructions executed: 34 execution time: 0.05 seconds | |
=> 3 | |
GEN-Eval: (define (interp-fact n) | |
(if (= 1 n) | |
n | |
(* n (interp-fact (- n 1))))) | |
;; total-stack-pushes: 3 maximum-stack-depth: 3 | |
;; instructions executed: 59 execution time: 0.05 seconds | |
=> INTERP-FACT | |
GEN-Eval: interp-fact | |
;; total-stack-pushes: 0 maximum-stack-depth: 0 | |
;; instructions executed: 18 execution time: 0.05 seconds | |
=> (Interpreted-procedure (N) ((IF (= 1 N) | |
N | |
(* N (INTERP-FACT (- N 1))))) <procedure-env>) | |
GEN-Eval: (compile (define (comp-fact n) | |
(if (= 1 n) | |
n | |
(* n (comp-fact (- n 1)))))) | |
;; total-stack-pushes: 0 maximum-stack-depth: 0 | |
;; instructions executed: 30 execution time: 0.05 seconds | |
=> COMP-FACT | |
GEN-Eval: comp-fact | |
;; total-stack-pushes: 0 maximum-stack-depth: 0 | |
;; instructions executed: 18 execution time: 0.05 seconds | |
=> <compiled-procedure> | |
GEN-Eval: (interp-fact 120) | |
;; total-stack-pushes: 2868 maximum-stack-depth: 365 | |
;; instructions executed: 38988 execution time: 0.0155 seconds | |
=> 6689502913449127057588118054090372586752746333138029810295671352301633557244962989366874165271984981308157637893214090552534408589408121859898481114389650005964960521256960000000000000000000000000000 | |
GEN-Eval: (comp-fact 120) | |
;; total-stack-pushes: 719 maximum-stack-depth: 359 | |
;; instructions executed: 5686 execution time: 0.0025 seconds | |
=> 6689502913449127057588118054090372586752746333138029810295671352301633557244962989366874165271984981308157637893214090552534408589408121859898481114389650005964960521256960000000000000000000000000000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment