Move timing out into a separate module
This commit is contained in:
parent
a16df8cca2
commit
fd1d3682f3
|
@ -6,7 +6,8 @@
|
|||
"syntax.rkt"
|
||||
"environment.rkt"
|
||||
"common.rkt"
|
||||
"special-forms.rkt")
|
||||
"special-forms.rkt"
|
||||
"timing.rkt")
|
||||
|
||||
(#%provide ambeval
|
||||
driver-loop)
|
||||
|
|
|
@ -5,26 +5,12 @@
|
|||
|
||||
(#%require "dd-mceval.rkt"
|
||||
"analyzing-mceval.rkt"
|
||||
"leval.rkt")
|
||||
"leval.rkt"
|
||||
"timing.rkt")
|
||||
|
||||
(#%require (only racket current-process-milliseconds))
|
||||
(#%require (only racket/base module+))
|
||||
|
||||
|
||||
;; Call proc on args n times and output the average time per run
|
||||
(define time-proc
|
||||
(lambda (iterations proc)
|
||||
(let ((start-time (current-process-milliseconds)))
|
||||
(let loop ((n iterations))
|
||||
(if (> n 0)
|
||||
(begin
|
||||
(proc)
|
||||
(loop (- n 1)))))
|
||||
(exact->inexact
|
||||
(/ (- (current-process-milliseconds)
|
||||
start-time)
|
||||
iterations)))))
|
||||
|
||||
(define (fact-program x)
|
||||
`((define (fact n)
|
||||
(if (= n 1) 1
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
#lang sicp
|
||||
|
||||
(#%require (only racket current-process-milliseconds))
|
||||
|
||||
(#%provide time-proc)
|
||||
|
||||
;; Call proc on args n times and output the average time per run
|
||||
(define time-proc
|
||||
(lambda (iterations proc)
|
||||
(let ((start-time (current-process-milliseconds)))
|
||||
(let loop ((n iterations))
|
||||
(if (> n 0)
|
||||
(begin
|
||||
(proc)
|
||||
(loop (- n 1)))))
|
||||
(exact->inexact
|
||||
(/ (- (current-process-milliseconds)
|
||||
start-time)
|
||||
iterations)))))
|
||||
|
Loading…
Reference in New Issue