- "Return the run time in the internal time format. (See
- INTERNAL-TIME-UNITS-PER-SECOND.) This is useful for finding CPU usage."
- (declare (values (unsigned-byte 32)))
- (multiple-value-bind (ignore utime-sec utime-usec stime-sec stime-usec)
- (sb!unix:unix-fast-getrusage sb!unix:rusage_self)
- (declare (ignore ignore)
- (type (unsigned-byte 31) utime-sec stime-sec)
- ;; (Classic CMU CL had these (MOD 1000000) instead, but
- ;; at least in Linux 2.2.12, the type doesn't seem to be
- ;; documented anywhere and the observed behavior is to
- ;; sometimes return 1000000 exactly.)
- (type (integer 0 1000000) utime-usec stime-usec))
- (let ((result (+ (the (unsigned-byte 32)
- (* (the (unsigned-byte 32) (+ utime-sec stime-sec))
- sb!xc:internal-time-units-per-second))
- (floor (+ utime-usec
- stime-usec
- (floor micro-seconds-per-internal-time-unit 2))
- micro-seconds-per-internal-time-unit))))
- result)))
+ "Return the run time used by the process in the internal time format. (See
+INTERNAL-TIME-UNITS-PER-SECOND.) This is useful for finding CPU usage.
+Includes both \"system\" and \"user\" time."
+ (system-internal-run-time))