Skip to content

Commit

Permalink
Replac ad-hoc use of get-time-of-day with precise-time
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinmera committed Jun 4, 2024
1 parent 9d21db1 commit 0fa7499
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
18 changes: 5 additions & 13 deletions toolkit.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -109,22 +109,14 @@
(dolist (sub (c2mop:class-direct-subclasses class))
(apply-class-changes sub)))

#+sbcl
(define-symbol-macro current-time-start
(load-time-value (logand (sb-ext:get-time-of-day) (1- (expt 2 32)))))

(declaim (inline current-time))
(defun current-time ()
(declare (optimize speed (safety 0)))
#+sbcl (multiple-value-bind (s ms) (sb-ext:get-time-of-day)
(let* ((s (logand s (1- (expt 2 62))))
(ms (logand ms (1- (expt 2 62)))))
(declare (type (unsigned-byte 62) s ms))
(+ (- s current-time-start)
(* ms
(coerce 1/1000000 'double-float)))))
#-sbcl (* (get-internal-real-time)
(coerce (/ internal-time-units-per-second) 'double-float)))
(multiple-value-bind (s ms) (org.shirakumo.precise-time:get-monotonic-time)
(let* ((s (logand s (1- (expt 2 62))))
(ms (logand ms (1- (expt 2 62)))))
(declare (type (unsigned-byte 62) s ms))
(+ s (* ms (load-time-value (coerce (/ org.shirakumo.precise-time:MONOTONIC-TIME-UNITS-PER-SECOND) 'double-float)))))))

(defmacro undefmethod (name &rest args)
(flet ((lambda-keyword-p (symbol)
Expand Down
1 change: 1 addition & 0 deletions trial.asd
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@
:mmap
:nibbles
:pathname-utils
:precise-time
:promise
:quickhull
:random-sampling
Expand Down

0 comments on commit 0fa7499

Please sign in to comment.