Skip to content

Commit

Permalink
Remove conditionals from profiling
Browse files Browse the repository at this point in the history
  • Loading branch information
Izaakwltn committed Oct 11, 2024
1 parent 194c079 commit 6b84f01
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions library/system.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
(:export
#:get-real-time
#:get-run-time
#+sbcl #:get-bytes-consed
#:get-bytes-consed
#:Profile
#:capture-profile)
(:export
Expand Down Expand Up @@ -86,13 +86,14 @@ While the result will always contain microseconds, some implementations may retu
(lisp UFix ()
(cl:get-internal-real-time)))

#+sbcl
(declare get-bytes-consed (Unit -> UFix))
#+sbcl
(declare get-bytes-consed (Unit -> (Optional UFix)))
(define (get-bytes-consed)
"Gets the number of bytes consed (only implemented for SBCL"
(lisp UFix ()
(sb-ext:get-bytes-consed)))
"Gets the number of bytes consed (only implemented in `SBCL`). "
(lisp (Optional UFix) ()
#+sbcl
(Some (sb-ext:get-bytes-consed))
#-sbcl
(None)))

(define-struct (Profile :a)
"A profile of a run function."
Expand All @@ -102,9 +103,8 @@ While the result will always contain microseconds, some implementations may retu
"The run time of the run" UFix)
(real-time
"The real time of the run" UFix)
#+sbcl
(bytes-consed
"The number of bytes consed during the run." UFix))
"The number of bytes consed during the run (will be None except in `SBCL`)." (Optional UFix)))

(declare capture-profile ((Unit -> :a) -> (Profile :a)))
(define (capture-profile f)
Expand All @@ -124,7 +124,9 @@ While the result will always contain microseconds, some implementations may retu
(- end-run-time start-run-time)
(- end-real-time start-real-time)
#+sbcl
(- end-bytes-consed start-bytes-consed)))))
(- end-bytes-consed start-bytes-consed)
#-sbcl
(None)))))

;;;
;;; Gathering System information
Expand Down

0 comments on commit 6b84f01

Please sign in to comment.