Skip to content

Instantly share code, notes, and snippets.

@inconvergent
Last active March 28, 2019 12:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save inconvergent/3718bee9d08de0b03bbf0f8fdf6c828d to your computer and use it in GitHub Desktop.
Save inconvergent/3718bee9d08de0b03bbf0f8fdf6c828d to your computer and use it in GitHub Desktop.
#!/usr/bin/sbcl --script
(declaim (inline rnd))
(defun rnd (a)
(declare (double-float a))
(the double-float (random (the double-float a))))
(declaim (inline sb-kernel::%random-fixnum))
(sb-ext:unlock-package 'sb-kernel)
(let ((n 300000000))
(time (loop repeat n do (rnd 10d0))) ; 3.226 seconds
(time (loop repeat n do (sb-kernel::%random-double-float 10d0 *random-state*))) ; 3.290 seconds
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment