Skip to content

Instantly share code, notes, and snippets.

@claj
Created May 12, 2014 19:58
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 claj/05043ddbda06356bd1a3 to your computer and use it in GitHub Desktop.
Save claj/05043ddbda06356bd1a3 to your computer and use it in GitHub Desktop.
Testing RNG
(ns clojurerng.core
(:import [com.modp.random LinearSunJDK])
(:use [ criterium.core]))
(def ^:LinearSunJDK linsun (LinearSunJDK.))
;;this is salvaged from
;; javarng.googlecode.com/svn/trunk/com/modp/random/LinearSunJDK.java
;;and the openJDK source code for .nextDouble
(comment (bench (.nextDouble linsun)))
;; Evaluation count : 3982185420 in 60 samples of 66369757 calls.
;; Execution time mean : 12.159947 ns
;; Execution time std-deviation : 0.144678 ns
;; Execution time lower quantile : 11.928112 ns ( 2.5%)
;; Execution time upper quantile : 12.494114 ns (97.5%)
;; Overhead used : 2.979788 ns
;;COMPARISATION WITH Math/random
(comment (bench (Math/random)))
;; Evaluation count : 1572240300 in 60 samples of 26204005 calls.
;; Execution time mean : 35.111262 ns
;; Execution time std-deviation : 0.344688 ns
;; Execution time lower quantile : 34.647129 ns ( 2.5%)
;; Execution time upper quantile : 35.827661 ns (97.5%)
;; Overhead used : 2.979788 ns
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment