Skip to content

Commit

Permalink
Changed the output format of the time primitive
Browse files Browse the repository at this point in the history
  • Loading branch information
egallesio committed May 1, 2024
1 parent 3a7565f commit b58c117
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/bonus.stk
Original file line number Diff line number Diff line change
Expand Up @@ -908,9 +908,9 @@ doc>
(,res (begin ,@args))
(,allocs (%thread-allocation-counter))
(,bytes (%thread-allocation-bytes)))
(eprintf " Elapsed time: ~S ms\n"
(eprintf "; Elapsed time: ~S ms\n"
(/ (- (exact-clock) ,time-start) 1000.0))
(eprintf " Allocations: ~S byte~A in ~S allocation call~A (GC: ~A)\n"
(eprintf "; Allocations: ~S byte~A in ~S allocation call~A (GC: ~A)\n"
,bytes (if (> ,bytes 1) "s" "") ,allocs (if (> ,allocs 1) "s" "")
(- (key-get (%gc-stats) #:gc-no 0) ,gc-no))
(%count-allocations ,counting?) ;; restore save state
Expand Down
6 changes: 3 additions & 3 deletions src/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,7 @@ char* STk_boot_consts = "#("
"fluid-let" " "
"(lambda (bindings . body) (let* ((vars (map car bindings)) (vals (map cadr bindings)) (tmps (map (lambda (x) (gensym)) vars))) `(let ,(map list tmps vars) (dynamic-wind (lambda () ,@(map (lambda (x y) `(set! ,x ,y)) vars vals)) (lambda () ,@body) (lambda () ,@(map (lambda (x y) `(set! ,x ,y)) vars tmps))))))" " "
"time" " "
"(lambda args (let ((time-start (gensym)) (res (gensym)) (counting? (gensym)) (allocs (gensym)) (bytes (gensym)) (gc-no (gensym))) `(let ((,counting? (%count-allocations)) (,gc-no (begin (gc) (key-get (%gc-stats) #:gc-no 0)))) (%thread-allocation-reset!) (%count-allocations #t) (let* ((,time-start (exact-clock)) (,res (begin ,@args)) (,allocs (%thread-allocation-counter)) (,bytes (%thread-allocation-bytes))) (eprintf \" Elapsed time: ~S ms\\n\" (/ (- (exact-clock) ,time-start) 1000.0)) (eprintf \" Allocations: ~S byte~A in ~S allocation call~A (GC: ~A)\\n\" ,bytes (if (> ,bytes 1) \"s\" \"\") ,allocs (if (> ,allocs 1) \"s\" \"\") (- (key-get (%gc-stats) #:gc-no 0) ,gc-no)) (%count-allocations ,counting?) ,res))))" " "
"(lambda args (let ((time-start (gensym)) (res (gensym)) (counting? (gensym)) (allocs (gensym)) (bytes (gensym)) (gc-no (gensym))) `(let ((,counting? (%count-allocations)) (,gc-no (begin (gc) (key-get (%gc-stats) #:gc-no 0)))) (%thread-allocation-reset!) (%count-allocations #t) (let* ((,time-start (exact-clock)) (,res (begin ,@args)) (,allocs (%thread-allocation-counter)) (,bytes (%thread-allocation-bytes))) (eprintf \"; Elapsed time: ~S ms\\n\" (/ (- (exact-clock) ,time-start) 1000.0)) (eprintf \"; Allocations: ~S byte~A in ~S allocation call~A (GC: ~A)\\n\" ,bytes (if (> ,bytes 1) \"s\" \"\") ,allocs (if (> ,allocs 1) \"s\" \"\") (- (key-get (%gc-stats) #:gc-no 0) ,gc-no)) (%count-allocations ,counting?) ,res))))" " "
"%count-allocations" " "
"gc" " "
"%gc-stats" " "
Expand All @@ -1001,9 +1001,9 @@ char* STk_boot_consts = "#("
"exact-clock" " "
"%thread-allocation-counter" " "
"%thread-allocation-bytes" " "
"\" Elapsed time: ~S ms\\n\"" " "
"\"; Elapsed time: ~S ms\\n\"" " "
"1000.0" " "
"\" Allocations: ~S byte~A in ~S allocation call~A (GC: ~A)\\n\"" " "
"\"; Allocations: ~S byte~A in ~S allocation call~A (GC: ~A)\\n\"" " "
"\"s\"" " "
"\"\"" " "
"\"s\"" " "
Expand Down

0 comments on commit b58c117

Please sign in to comment.