Git Product home page Git Product logo

scala-xoroshiro128's Introduction

xoroshiro128+ in Scala

CircleCI

Source: https://github.com/mscharley/scala-xoroshiro128
Author: Matthew Scharley
Contributors: See contributors on GitHub
Bugs/Support: Github Issues
Copyright: 2017
License: CC0
Status: Active

Synopsis

This is an implementation of the xoroshiro128+ algorithm in Scala for a laugh.

License

Original implementation: http://xorshift.di.unimi.it/

To the extent possible under law, the author has dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.

See http://creativecommons.org/publicdomain/zero/1.0/.

Usage

"com.mscharley" %%% "xoroshiro128" % "0.2.0"

Benchmark

A likely non-representative benchmark run on my computer:

[info] Running JvmBenchmark
Benchmarking 8000000 bytes of data x100:
Long:     s.u.Random - 23.93999266 ms, xoroshiro128 - 1.1129802500000003 ms; 95.35095826549849% improvement
Int:      s.u.Random - 23.85083168000001 ms, xoroshiro128 - 2.2173956100000005 ms; 90.70306796949397% improvement
Short:    s.u.Random - 48.22186773000002 ms, xoroshiro128 - 4.59222692 ms; 90.47687877683953% improvement
Bytes(s): s.u.Random - 29.75306531 ms, xoroshiro128 - 19.856193739999995 ms; 33.26336788120338% improvement
Bytes(l): s.u.Random - 24.804027829999995 ms, xoroshiro128 - 11.763384149999997 ms; 52.57470185639605% improvement
Bytes:    s.u.Random - 26.417548529999998 ms, xoroshiro128 - 11.995912270000012 ms; 54.59112242615036% improvement
Boolean:  s.u.Random - 95.77337273999997 ms, xoroshiro128 - 9.00962081 ms; 90.5927706707596% improvement
[success] Total time: 38 s, completed 26/03/2017 8:40:11 PM
[info] running
[info] /.../scala-xoroshiro128/benchmark/native/target/scala-2.11/xoroshiro128-benchmark-out
Benchmarking 8000000 bytes of data x100:
Long:     s.u.Random - 12.937738 ms, xoroshiro128 - 5.330703 ms; 58.797255% improvement
Int:      s.u.Random - 16.519583 ms, xoroshiro128 - 14.059075 ms; 14.894493% improvement
Short:    s.u.Random - 32.537838 ms, xoroshiro128 - 27.262902 ms; 16.211699% improvement
Bytes(s): s.u.Random - 116.925888 ms, xoroshiro128 - 113.690834 ms; 2.766756% improvement
Bytes(l): s.u.Random - 75.950144 ms, xoroshiro128 - 68.031258 ms; 10.426427% improvement
Bytes:    s.u.Random - 73.362115 ms, xoroshiro128 - 64.498381 ms; 12.082168% improvement
Boolean:  s.u.Random - 78.030979 ms, xoroshiro128 - 76.605007 ms; 1.827442% improvement
[info] Running JsBenchmark
Benchmarking 8000000 bytes of data x100:
Long:     s.u.Random - 85.66000127999997 ms, xoroshiro128 - 73.38000128 ms; 14.335745758233054% improvement
Int:      s.u.Random - 53.82000128000001 ms, xoroshiro128 - 103.03999999999998 ms; -91.45298689966876% improvement
Short:    s.u.Random - 106.64000256 ms, xoroshiro128 - 210.44999936 ms; -97.34620621524486% improvement
Bytes(s): s.u.Random - 120.88999936 ms, xoroshiro128 - 552.23000064 ms; -356.80370879604897% improvement
Bytes(l): s.u.Random - 63.909998080000015 ms, xoroshiro128 - 437.02000128 ms; -583.805373821097% improvement
Bytes:    s.u.Random - 96.52999936 ms, xoroshiro128 - 475.77999872 ms; -392.88304348332275% improvement
Boolean:  s.u.Random - 365.33999872 ms, xoroshiro128 - 578.13999104 ms; -58.247110380895364% improvement

To run this benchmark for yourself: sbt benchmarkJVM/run

Verification

You can always download and compile the reference C implementation and compare output. To aid in that endeavour I've put up an online version which you can use to easily generate sequences of values.

There's also a set of prebuilt comparisons against the reference built into the test suite which you can run with sbt test.

Releases

Snapshots

sbt publishSigned

Full Releases

sbt publishSigned sonatypeRelease

scala-xoroshiro128's People

Contributors

mscharley avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

scala-xoroshiro128's Issues

Do releases!

I have a OSSRH account now, may as well do releases of this.

Add tests based on the reference implementation in C.

See https://ideone.com/hwDnTY for an executable version.

Example output:

Generating random sequences for the SplitMix algorithm.
Initial seed: 1513817156475045394
-3626855871036418500
5037142008337821566
-3562918846162485440
6147600479854282459
-2107227943531753716
7305139801090763158
45944157781804797
-7238041443203849113
4935327494810927
-7465686127882598073
878344852229720568
3574408971783286528
9214682511526103307
729294334327866990
7597411072756597084
-2629190600061795611
-7244729470018064912
-7593388130241446607
1606672671596115209
-962285391878890975

Initial seed: -3624042228962942470
-8093141376403486867
-1660797054317164888
-5301483877711544407
1053859684402764631
-8809592461628447777
-56351121158468066
-5516092378996299582
1478019966702993026
-6961362406803094976
4527174060234373935
-6985005261186685921
-2631743966849514590
-9000478326812591951
-6592178640585358827
-1520793705359419990
8438955686061858502
3127114024932263503
2969998919417794721
-400589350608139551
3909748544636780242

Initial seed: 3531207199216388937
-3206994160392332939
-4012469958504412667
7688722805700151260
-8186447116185818914
9119627738804668866
6465616336965940866
7272417000192644268
2400378858552795454
9211185551331753954
6324808756497678386
-596204120810283059
-4204049282940173092
2993640038985319438
-9046652693398636704
-1927112923864687358
7331671517499201742
-2549640936755132433
-7358605727140964702
4727220835533094256
1137108542316277383

Initial seed: 608525831176989228
7458925378891065981
-4668862760993682703
145865224688153713
7619562588402593909
8947804235711737461
652799901022242297
-4132423561366547548
-108239521146601457
4720074345220598289
-3704014221621206302
1089816034498358065
-1537844168084212989
8376087376569079188
4709888078107164101
-5917848797594813537
8659727343914311863
-2264127904877668051
9185121410365109402
-6970381369069289732
-3337446517345151332

Initial seed: 2243454288033855382
-5828467925148123703
-5879922502433020984
-8558671607890461517
-3891284283703580998
-2710682958278085780
-744668874983046469
1008577969107082690
7753778749835104823
-6252953929927214019
-736347964098444110
-7561126437727570687
-5957881925139424809
7582844502024937043
-1411151789159259645
-2903941993630572853
-8206466541304161149
4976485895977455496
-5374008580841091950
1572495047076487624
-4112667763505259621

Generating random sequences for the xoroshiro128+ algorithm.
Initial seed: -4823001311516472710 5949705871595575025
1126704560079102315
8796220148548794092
-4351969099738545414
1115233890897963686
-341761134134357137
561071025051741906
7204848339415919354
-5077512656280648866
-7692946770369052564
-5063691591573174986
-8897635170497897013
-4199644625846217191
-3544348651434211969
-8079455476894169506
2282080123371869556
911121917961546834
6723482648633717420
-4958475521373389720
-3920040866770853183
-4755577245976293940
Initial seed: 1102771779858531533 643457051388719267
Jump 1: -1121066719408722450
Jump 2: 4310360820389066569
Jump 3: -4735575553454220855
Jump 4: 2031889585379281199
Jump 5: 9076795753267445372

Initial seed: -8884722907433852130 8146936488925077760
-737786418508774370
6831977746526376659
-734363475961070821
3788769925105748835
3799516942461692233
8804496836120406215
4502452080417126604
5209256213827142104
-1703926729889892294
-1182984859477871877
-8258912817497329266
5439129394363390135
-2332636081785475949
3894877403224897644
4134836962150761698
-4211433016749793336
-7811640793330326446
-8425551450224688233
-2263292161856299489
4461705904392488931
Initial seed: -5344967088887150224 5818293704100131212
Jump 1: -85059822157568920
Jump 2: 676681078346374995
Jump 3: 8588231856713208773
Jump 4: 2458078194507175768
Jump 5: 5395811063313778175

Initial seed: -3257375370828617351 -8531679432501196045
6657689270379738220
9222059235171711446
-4201421472743020540
-1739444642814636745
-4973628781447893868
2949181541447815382
1026652562213478519
7697981051981754047
-5336402384342581149
-1668375935023408037
4890366791825267198
6451536666718856816
948536817248600930
-4696574786751313290
5504654956598266192
-4872348553376800030
4123719448275272283
-9077443904670060386
3174136521224631338
-1292006535315758191
Initial seed: 3474006459889022751 8747996624229533430
Jump 1: 1494822226157619902
Jump 2: -3569493440756261250
Jump 3: -5177630526149539193
Jump 4: 1778474867892139208
Jump 5: 2791801284711883546

Initial seed: 9097977738086587765 3108145906336681618
-6240620429286282233
2267394554003498845
-4852688425837652380
167972505769480039
1359621195529982136
1246879650983237670
6867699725247969716
-654784861732131297
4104952218497892293
-7942884659741072784
-733604084842556135
-685596469640985328
-5625263263866414292
890001196481155838
-2704766674184838333
-7147039749947577753
-7322299218734396026
2284453502422000668
-3635723251788242046
4518012520836113769
Initial seed: -6846533767144302270 -1576422842483684744
Jump 1: 5310437083479555798
Jump 2: 9128934508599744339
Jump 3: -7577489496686026435
Jump 4: 4503525820096706339
Jump 5: 8130558390339035774

Initial seed: -7309683336934465458 2484182486618374754
-4825500850316090704
6727637936987884581
3038070578391046784
3608526543373619137
-2570440528851677431
-3486267192874186600
-5765880127275252188
5837093774754120939
2788900921353569322
6387034569474398275
5381503650835844894
2374988773823429462
-8528864665156310533
1978884599989166701
888761003258314467
2541457442086701700
-8224173321358362540
-5561700290344507424
-7520354970005942974
3156150446074668489
Initial seed: -7863438128679380534 -4356936658572020450
Jump 1: 7130612728359616740
Jump 2: -7676912791371400518
Jump 3: 4616951799952053638
Jump 4: 8431453370959560637
Jump 5: 8535454460642049136

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.