(in-package "SB!IMPL")
-(defconstant internal-time-units-per-second 100
+(defconstant sb!xc:internal-time-units-per-second 1000
#!+sb-doc
"The number of internal time units that fit into a second. See
GET-INTERNAL-REAL-TIME and GET-INTERNAL-RUN-TIME.")
(defconstant micro-seconds-per-internal-time-unit
- (/ 1000000 internal-time-units-per-second))
+ (/ 1000000 sb!xc:internal-time-units-per-second))
\f
;;; The base number of seconds for our internal "epoch". We initialize
;;; this to the time of the first call to GET-INTERNAL-REAL-TIME, and
(truly-the (unsigned-byte 32)
(+ (the (unsigned-byte 32)
(* (the (unsigned-byte 32) (- seconds base))
- internal-time-units-per-second))
+ sb!xc:internal-time-units-per-second))
uint)))
(t
(setq *internal-real-time-base-seconds* seconds)
(let ((result (+ (the (unsigned-byte 32)
(* (the (unsigned-byte 32) (+ utime-sec stime-sec))
- internal-time-units-per-second))
+ sb!xc:internal-time-units-per-second))
(floor (+ utime-usec
stime-usec
(floor micro-seconds-per-internal-time-unit 2))
(defun get-universal-time ()
#!+sb-doc
- "Returns a single integer for the current time of
+ "Return a single integer for the current time of
day in universal time format."
(multiple-value-bind (res secs) (sb!unix:unix-gettimeofday)
(declare (ignore res))
(defun get-decoded-time ()
#!+sb-doc
- "Returns nine values specifying the current time as follows:
+ "Return nine values specifying the current time as follows:
second, minute, hour, date, month, year, day of week (0 = Monday), T
(daylight savings times) or NIL (standard time), and timezone."
(decode-universal-time (get-universal-time)))
(defmacro time (form)
#!+sb-doc
- "Evaluates the Form and prints timing information on *Trace-Output*."
+ "Execute FORM and print timing information on *TRACE-OUTPUT*."
`(%time #'(lambda () ,form)))
-;;; Try to compile the closure arg to %TIME if it is interpreted.
-(defun massage-time-function (fun)
- ;; This is just a placeholder as of the switch from IR1 interpreter
- ;; to bytecode interpreter. Someday it might make sense to complain
- ;; about bytecoded FUN and/or compile it to native code, so I've
- ;; left the placeholder in place, but as of sbcl-0.7.0 it's not
- ;; obvious how to do the right thing easily, so I haven't actually
- ;; done it. -- WHN
- fun)
-
;;; Return all the data that we want TIME to report.
(defun time-get-sys-info ()
(multiple-value-bind (user sys faults) (sb!sys:get-system-info)
;;; The guts of the TIME macro. Compute overheads, run the (compiled)
;;; function, report the times.
(defun %time (fun)
- (let ((fun (massage-time-function fun))
- old-run-utime
+ (let (old-run-utime
new-run-utime
old-run-stime
new-run-stime
~S page fault~:P and~% ~
~S bytes consed.~%"
(max (/ (- new-real-time old-real-time)
- (float internal-time-units-per-second))
+ (float sb!xc:internal-time-units-per-second))
0.0)
(max (/ (- new-run-utime old-run-utime) 1000000.0) 0.0)
(max (/ (- new-run-stime old-run-stime) 1000000.0) 0.0)
(unless (zerop gc-run-time)
(/ (float gc-run-time)
- (float internal-time-units-per-second)))
+ (float sb!xc:internal-time-units-per-second)))
(max (- new-page-faults old-page-faults) 0)
(max (- new-bytes-consed old-bytes-consed) 0)))))))