Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A collection of Pseudo Random Number Generator (PRNG) for .NET

License

NotificationsYou must be signed in to change notification settings

Shiroechi/Litdex.Security.RNG

Repository files navigation

This library will not be continued and will not recieve bug fix or new update in the future. UseLitdex.Random in exchange Litdex.Security.RNG.

Library that provide basic random generator function and was inspired from Pythonrandom.py.

Litdex.Security.RNG have already provide some basic random algorithm, so you can use it immediately rather than implement it yourself. But, stillLitdex.Security.RNG created with extensibility in mind, so you can implement your ownrandom generator with thislibrary.

Note: This is sub-modlue ofLitdex.

CodeFactor

Download

Nuget

Nuget

This package contains:

CurrentlyLitdex.Security.RNG support this algorithm:

All of the algorithm have passing Practrand or Test01 test. But I've never test it individually, the author who is said that their algorithm past Practrand or Test01.

You can check in this website"PRNG Battle Royale: 47 PRNGs � 9 consoles", the writer have tested some of the algorithm that have been implemented.

How to use

For detailed use, readHow to useorDocumentation

The simple way to use

// create rng objectvarrng=newXoroshiro128plus();// get random integervarrandomInt=rng.NextInt();

Want to create your own RNG?? Then readCustom RNG

Benchmark

32-bit RNG

BenchmarkDotNet=v0.13.1,OS=Windows 10.0.18363.1500 (1909/November2019Update/19H2)AMD FX-8800P Radeon R7, 12 Compute Cores 4C+8G, 1 CPU, 4 logical and 4 physical cores.NETSDK=5.0.401  [Host]    : .NET 5.0.10 (5.0.1021.41214), X64 RyuJIT  MediumRun : .NET 5.0.10 (5.0.1021.41214), X64 RyuJITJob=MediumRunIterationCount=15LaunchCount=2WarmupCount=10
MethodrandMeanErrorStdDevMinMaxRatioRatioSDRankGen 0Allocated
System.Random?5,320.380 ns30.5306 ns45.6968 ns5,256.942 ns5,395.361 ns1.000.0010.5341280 B
NextIntJSF 32-bit9.559 ns0.1051 ns0.1507 ns9.291 ns9.994 ns??1--
NextIntJSF 3(...)otate [24]10.283 ns0.0942 ns0.1410 ns10.099 ns10.522 ns??1--
NextIntMiddl(...)uence [27]12.428 ns0.0641 ns0.0920 ns12.310 ns12.694 ns??1--
NextIntPCG XSH-RR 32-bit12.805 ns0.0962 ns0.1380 ns12.547 ns13.106 ns??1--
NextIntPCG XSH-RS 32-bit10.849 ns0.6821 ns1.0210 ns8.613 ns12.409 ns??1--
NextIntRomu Mono 32-bit11.347 ns0.0834 ns0.1169 ns11.136 ns11.532 ns??1--
NextIntRomu Quad 32-bit10.316 ns0.1106 ns0.1621 ns10.075 ns10.737 ns??1--
NextIntRomu Trio 32-bit13.664 ns0.1315 ns0.1886 ns13.373 ns14.166 ns??1--
NextIntSFC 32-bit10.270 ns0.0651 ns0.0934 ns10.090 ns10.427 ns??1--
NextIntSquares13.174 ns0.0892 ns0.1307 ns12.936 ns13.476 ns??1--
NextIntTyche49.391 ns0.2749 ns0.4114 ns48.846 ns49.951 ns??1--
NextIntTyche-i20.308 ns0.1033 ns0.1481 ns20.078 ns20.541 ns??1--

64-bit RNG

BenchmarkDotNet=v0.13.1,OS=Windows 10.0.18363.1500 (1909/November2019Update/19H2)AMD FX-8800P Radeon R7, 12 Compute Cores 4C+8G, 1 CPU, 4 logical and 4 physical cores.NETSDK=5.0.401  [Host]    : .NET 5.0.10 (5.0.1021.41214), X64 RyuJIT  MediumRun : .NET 5.0.10 (5.0.1021.41214), X64 RyuJITJob=MediumRunIterationCount=15LaunchCount=2WarmupCount=10
MethodrandMeanErrorStdDevMinMaxRankGen 0Allocated
NextLongRomu Duo 64-bit5.547 ns0.0658 ns0.0985 ns5.356 ns5.748 ns1--
NextLongRomu Duo Jr 64-bit5.583 ns0.0647 ns0.0948 ns5.415 ns5.853 ns1--
NextLongShioi5.779 ns0.0587 ns0.0861 ns5.635 ns5.930 ns2--
NextLongSeiran5.815 ns0.0835 ns0.1198 ns5.623 ns6.113 ns2--
NextLongXoroshiro 128+5.835 ns0.0745 ns0.1068 ns5.632 ns6.007 ns2--
NextLongXoroshiro 128**5.965 ns0.0624 ns0.0914 ns5.841 ns6.186 ns3--
NextLongPCG RXS-M-XS 64-bit6.162 ns0.0653 ns0.0957 ns5.981 ns6.345 ns4--
NextLongSplitMix646.751 ns0.0550 ns0.0753 ns6.642 ns6.948 ns5--
NextLongXoroshiro 128++6.812 ns0.5558 ns0.8318 ns5.865 ns7.779 ns5--
NextLongRomu Trio 64-bit7.095 ns0.0581 ns0.0851 ns6.964 ns7.266 ns5--
NextLongRomu Quad 64-bit7.684 ns0.0862 ns0.1291 ns7.498 ns7.907 ns6--
NextLongSFC 64-bit7.842 ns0.0950 ns0.1393 ns7.582 ns8.023 ns7--
NextLongJSF 64-bit8.376 ns0.1285 ns0.1923 ns8.171 ns8.872 ns8--
NextLongXoshiro 256**9.460 ns0.0708 ns0.0993 ns9.350 ns9.676 ns9--
NextLongXoshiro 256+9.494 ns0.0752 ns0.1125 ns9.316 ns9.661 ns9--
NextLongXoshiro 256++9.692 ns0.0936 ns0.1401 ns9.482 ns9.940 ns10--
NextLongWyrand11.949 ns0.1327 ns0.1986 ns11.639 ns12.344 ns11--
NextLongXoshiro 512++17.201 ns0.1145 ns0.1713 ns16.926 ns17.487 ns12--
NextLongXoshiro 512+17.292 ns0.2144 ns0.3005 ns16.951 ns17.872 ns12--
NextLongXoshiro 512**17.425 ns0.2050 ns0.3069 ns16.905 ns17.904 ns12--
NextLongGjrand25.934 ns0.2945 ns0.4408 ns24.915 ns26.314 ns13--
NextLongShishua30.672 ns0.4714 ns0.6909 ns29.746 ns31.842 ns140.030616 B

Warning

For method that generate an arbitary byte array, like methodNextBytes.

varrng=newXoroshiro128plus();varbytes=rng.NextBytes(10);

Litdex generate the array using multipleuint orulong, eachuint orulong will converted into byte array. When converted to byte array, Litdex order the byte based on the system endianess. Then each converted byte array will be concated with other byte array.

Contribute

Feel free to open newissue orPR.

Donation

Like this library? Please consider donation

ko-fi


[8]ページ先頭

©2009-2025 Movatter.jp