@@ -155,10 +155,38 @@ (append (list 0 *default-log-port* (conc color-on location "@"(/ (- (current-milliseconds) *BB-process-starttime*) 1000) color-off " ") ) in-args))) (apply debug:print dp-args)))) + +(define *BBprofile-hash* (make-hash-table)) +(define (BBprofile-thunk procname thunk) + (let* ((old-proctally (hash-table-ref/default *BBprofile-hash* procname + '(0 . 0))) + (old-proccalls (car old-proctally)) + (old-procduration (cdr old-proctally)) + (before-ms (current-milliseconds)) + (res (thunk)) + (after-ms (current-milliseconds)) + (duration (/ (- after-ms before-ms) 1000)) + (proccalls (add1 old-proccalls)) + (procduration (+ duration old-procduration))) + (hash-table-set! *BBprofile-hash* procname + (cons proccalls procduration)) + (BB> "@@@@ called "procname" ; duration="duration" ; totcalls="proccalls + " avg="(/ procduration proccalls)" tot="procduration) + res)) +(define (BBprofile . in-args) + (let* ((proc (car in-args)) + (args (cdr in-args)) + (procname (symbol->string (car (procedure-information proc)))) + (thunk (lambda () + (apply proc args)))) + (BBprofile-thunk procname thunk))) + + + (define *BBpp_custom_expanders_list* (make-hash-table))