|
|
|
|
|
by tomatsu
3091 days ago
|
|
https://github.com/mohae/bench-rng csprng: 909 ns/Op Xorhift128+: 2 ns/Op Xorhift128+ is what all major JS engines use for Math.random(). I don't think it's a good idea if you use a CSPRNG if there isn't any reason for that. Especially if you need a lot of random numbers. E.g. a game might drop some additional frames here and there and your particle effects won't look any better and your AI won't behave any smarter either. Not to use PRNGs ever is bad advice. |
|
OK, go ships a lousy csprng. I've been asking the team to replace it but no one has gotten around to it. AES-CTR, for example, is competitive with Xorshift and Xoroshiro.
> Xorshift128+ is what all major JS engines use for Math.random().
Only because two years ago Yang Guo noticed that MWC1616 was garbage. Up until that point engines were shipping a broken generator because someone had been clever. This failure mode happens again and again. java.util.Random, for example.
> I don't think it's a good idea if you use a CSPRNG if there isn't any reason for that
Using insecure random sources opens you up to all sorts of attacks that CSPRNGs insulate you to.
> Especially if you need a lot of random numbers
Over the past year I profiled a huge number of binaries. I found exactly one where fetching random numbers was over 1% of CPU consumption.
> your particle effects won't look any better
Your particle effects are probably running in a shader. That's a whole other ball game.