valyala / fastrand Goto Github PK
View Code? Open in Web Editor NEWFast and scalable pseudorandom generator for Go
License: MIT License
Fast and scalable pseudorandom generator for Go
License: MIT License
Library is really great for benchmark purposes when one needs to generate lots of random data to feed to some procesing.
But lack of Seed()
function makes it difficult to debug code.
Hello, first thanks for that small code, it's interesting!
I'm trying to solve this with it, for the fun of it.
Now regarding the sync.Pool
, I'm not sure this is so much per CPU than it is per goroutine.
If you have 1000 goroutines at the same time, there will be 1000 RNG objects (well just 1000x 1 uint32 really so that's fine memory wise).
Indeed if you have 4 CPU intensive goroutines on a 4 core CPU, there will be one RNG per core but that's a particular case.
Should we mention that in the readme?
There is also another problem: if you launch 1000 goroutines at start, it 'could' create 1000 RNG initialized with the same time (unlikely, but it can happen on certain systems with bad time resolution) and that can lead to a quite bad pseudo randomness.
Maybe a solution would be to use crypto/rand
the first time when creating the RNG
object via the sync.Pool's New
field function?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.