New `xrepl' collection.
This commit is contained in:
parent
adeef671cd
commit
c544ebfe6c
|
@ -511,6 +511,9 @@ mz-extras :+= (collects: "rnrs/")
|
|||
;; -------------------- readline
|
||||
mz-extras :+= (package: "readline/")
|
||||
|
||||
;; -------------------- readline
|
||||
mz-extras :+= (package: "xrepl/")
|
||||
|
||||
;; -------------------- wxme
|
||||
mz-extras :+= (collects: "wxme/")
|
||||
|
||||
|
|
|
@ -2069,6 +2069,7 @@ path/s is either such a string or a list of them.
|
|||
"collects/xml/text-box-tool.rkt" drdr:command-line (gracket-text "-t" *)
|
||||
"collects/xml/text-snipclass.rkt" drdr:command-line (gracket-text "-t" *)
|
||||
"collects/xml/xml-snipclass.rkt" drdr:command-line (gracket-text "-t" *)
|
||||
"collects/xrepl" responsible (eli)
|
||||
"doc/release-notes/COPYING-libscheme.txt" responsible (mflatt)
|
||||
"doc/release-notes/COPYING.txt" responsible (mflatt)
|
||||
"doc/release-notes/drracket" responsible (robby)
|
||||
|
|
49
collects/unstable/time.rkt
Normal file
49
collects/unstable/time.rkt
Normal file
|
@ -0,0 +1,49 @@
|
|||
#lang racket/base
|
||||
|
||||
;; An improved `time' variant: better output, and repetitions with averages
|
||||
(provide time)
|
||||
|
||||
(require racket/list)
|
||||
|
||||
(define (time* thunk times)
|
||||
(define throw
|
||||
(if (<= times 0)
|
||||
(error 'time "bad count: ~e" times)
|
||||
(floor (* times 2/7))))
|
||||
(define results #f)
|
||||
(define timings '())
|
||||
(define (run n)
|
||||
(when (<= n times)
|
||||
(when (> times 1) (printf "; run #~a..." n) (flush-output))
|
||||
(let ([r (call-with-values (lambda () (time-apply thunk '())) list)])
|
||||
(set! results (car r))
|
||||
(set! timings (cons (cdr r) timings))
|
||||
(when (> times 1)
|
||||
(printf " ->")
|
||||
(if (null? results)
|
||||
(printf " (0 values returned)")
|
||||
(begin (printf " ~.s" (car results))
|
||||
(for ([r (in-list (cdr results))]) (printf ", ~s" r))
|
||||
(newline))))
|
||||
(run (add1 n)))))
|
||||
(collect-garbage)
|
||||
(collect-garbage)
|
||||
(collect-garbage)
|
||||
(run 1)
|
||||
(set! timings (sort timings < #:key car)) ; sort by cpu-time
|
||||
(set! timings (drop timings throw)) ; throw extreme bests
|
||||
(set! timings (take timings (- (length timings) throw))) ; and worsts
|
||||
(set! timings (let ([n (length timings)]) ; average
|
||||
(map (lambda (x) (round (/ x n))) (apply map + timings))))
|
||||
(let-values ([(cpu real gc) (apply values timings)])
|
||||
(when (> times 1)
|
||||
(printf "; ~a runs, ~a best/worst removed, ~a left for average:\n"
|
||||
times throw (- times throw throw)))
|
||||
(printf "; cpu time: ~sms = ~sms + ~sms gc; real time: ~sms\n"
|
||||
cpu (- cpu gc) gc real))
|
||||
(apply values results))
|
||||
|
||||
(define-syntax time
|
||||
(syntax-rules ()
|
||||
[(_ n expr0 expr ...) (time* (lambda () expr0 expr ...) n)]
|
||||
[(_ expr0 expr ...) (time* (lambda () expr0 expr ...) 1)]))
|
3
collects/xrepl/info.rkt
Normal file
3
collects/xrepl/info.rkt
Normal file
|
@ -0,0 +1,3 @@
|
|||
#lang setup/infotab
|
||||
|
||||
(define name "eXtended REPL")
|
13
collects/xrepl/main.rkt
Normal file
13
collects/xrepl/main.rkt
Normal file
|
@ -0,0 +1,13 @@
|
|||
#lang racket/base
|
||||
|
||||
;; This file is intended to be loaded from your init file (evaluatue
|
||||
;; (find-system-path 'init-file) to see where that is on your OS.)
|
||||
|
||||
(require "xrepl.rkt")
|
||||
|
||||
;; may want to disable inlining to allow redefinitions
|
||||
;; (compile-enforce-module-constants #f)
|
||||
|
||||
;; create the command repl reader, and value-saving evaluator
|
||||
(current-prompt-read (make-command-reader))
|
||||
(current-eval (make-command-evaluator (current-eval)))
|
1245
collects/xrepl/xrepl.rkt
Normal file
1245
collects/xrepl/xrepl.rkt
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user