Plaster
New
List
Login
text
default
anonymous
2024.01.24 16:21:17
PCG 215300000 MERSENNE-TWISTER-32 166600000 XOSHIRO-128+ 152600000 XORSHIFT-32 150300000 RC4 147000000 XOSHIRO-128** 142900000 TT800 139700000 XORSHIFT-128 137500000 SQUIRREL 137400000 XOSHIRO-128++ 136200000 ADLER32 135200000 XORWOW 134500000 KISS11 133300000 MURMURHASH3 106300000 XOROSHIRO-64* 97500000 XOROSHIRO-128+ 90500000 XOROSHIRO-128++ 88300000 XOROSHIRO-64** 83800000 XOROSHIRO-128** 78700000 XOSHIRO-256** 68400000 XOSHIRO-256+ 63700000 XOSHIRO-256++ 62000000 XORSHIFT-128+ 59800000 XORSHIFT-64 58500000 XORSHIFT-64* 56800000 XORSHIFT-1024* 56400000 MERSENNE-TWISTER-64 51800000 MIDDLE-SQUARE 24700000 LINEAR-CONGRUENCE 9200000 SOBOL 2100000 HAMMERSLEY 1200000 CITYHASH-64 -1 RANDOM-STATE -1 PCG 168510000 MERSENNE-TWISTER-32 142320000 XOSHIRO-128+ 131760000 RC4 129260000 SQUIRREL 124950000 XORSHIFT-128 123860000 TT800 122890000 KISS11 119140000 XOSHIRO-128** 118840000 XORSHIFT-32 118060000 XOSHIRO-128++ 117870000 XORWOW 114370000 ADLER32 113400000 MURMURHASH3 94140000 XOROSHIRO-64* 89090000 XOROSHIRO-128+ 84300000 XOROSHIRO-64** 81440000 XOROSHIRO-128++ 81210000 XOROSHIRO-128** 79030000 XOSHIRO-256** 61900000 XOSHIRO-256+ 57630000 XOSHIRO-256++ 57630000 XORSHIFT-128+ 55570000 XORSHIFT-1024* 54970000 MERSENNE-TWISTER-64 52800000 XORSHIFT-64 51740000 XORSHIFT-64* 51600000 MIDDLE-SQUARE 23570000 LINEAR-CONGRUENCE 9570000 SOBOL 2070000 HAMMERSLEY 1150000 CITYHASH-64 -1 RANDOM-STATE -1
Raw
Annotate
Repaste
Edit
Annotations
common-lisp
default
anonymous
2024.01.24 16:25:33
(defun benchmark (rng &key (duration 10.0) (stream *standard-output*)) (let* ((rng (ensure-generator rng)) (*package* (find-package '#:org.shirakumo.random-state)) (next-fun (fdefinition (intern* (type-of rng) 'next))) (duration (float duration 0d0)) (units (ceiling (* INTERNAL-TIME-UNITS-PER-SECOND duration))) (samples 0) (start (get-internal-run-time))) (declare (type fixnum samples units)) (declare (type (function (generator) T) next-fun)) (locally (declare (optimize speed (safety 0))) (loop for current = (get-internal-run-time) until (< units (- current start)) do (loop repeat 100000 do (funcall next-fun rng) (incf samples)))) (format stream "Duration: ~12t~10,1f~%Samples: ~12t~10d~%Samples/s: ~12t~10,1f~%S/sample: ~12t~10,8f" duration samples (/ samples duration) (/ duration samples)) samples)) (defun benchmark-all (&key (duration 10.0) (stream *standard-output*)) (let* ((nullstream (make-broadcast-stream)) (stats (loop for rng in (list-generator-types) for result = (cons rng (handler-case (benchmark rng :duration duration :stream nullstream) (error (e) (format t "~a:~a?~%" rng e) -1))) do (format t "~s~%" result) when result collect result))) (setf stats (sort stats #'> :key #'cdr)) (loop for (rng . samples) in stats do (format stream "~&~a~20t~10d~%" rng samples))))
Raw
Repaste
Edit