Add primitive timing to ambeval
This shows the cumulative number of milliseconds in the current problem
This commit is contained in:
parent
a457194e11
commit
6df1a27539
|
@ -9,6 +9,9 @@
|
|||
"special-forms.rkt"
|
||||
"timing.rkt")
|
||||
|
||||
(#%require (only racket current-process-milliseconds))
|
||||
(#%require (only racket string-append))
|
||||
|
||||
(#%provide ambeval
|
||||
amb-driver-loop
|
||||
amb-eval-program)
|
||||
|
@ -198,6 +201,7 @@
|
|||
;; Need to pass success and failure continuations to ambeval, so
|
||||
;; will probably need a different eval-program.
|
||||
(amb-eval-program-in-env amb-utilities-program env)
|
||||
(define start-time 0)
|
||||
(define (internal-loop try-again)
|
||||
(prompt-for-input input-prompt)
|
||||
(let ((input (read)))
|
||||
|
@ -206,17 +210,23 @@
|
|||
(begin
|
||||
(newline)
|
||||
(display ";;; Starting a new problem ")
|
||||
(set! start-time (current-process-milliseconds))
|
||||
(ambeval input
|
||||
env
|
||||
;; ambeval success
|
||||
(lambda (val next-alternative)
|
||||
(newline)
|
||||
(announce-output output-prompt)
|
||||
(display (- (current-process-milliseconds) start-time))
|
||||
(newline)
|
||||
(user-print val)
|
||||
(internal-loop next-alternative))
|
||||
;; ambeval failure
|
||||
(lambda ()
|
||||
(announce-output
|
||||
";;; There are no more values of")
|
||||
(display (- (current-process-milliseconds) start-time))
|
||||
(newline)
|
||||
(user-print input)
|
||||
(amb-driver-loop)))))))
|
||||
(internal-loop
|
||||
|
|
Loading…
Reference in New Issue