Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #11832
| From | David Brown <david.brown@hesbynett.no> |
|---|---|
| Newsgroups | comp.programming |
| Subject | Re: Increasing random() function speed. |
| Date | 2021-01-18 12:15 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <ru3qju$fft$1@dont-email.me> (permalink) |
| References | <88789e3e-9f73-4e6b-b42f-27ff7e24565an@googlegroups.com> |
On 18/01/2021 12:07, H e wrote: > I have noticed, that JavaScript Math.random() is a little bit slow. Please stop posting this. You are wrong - you simply don't understand how to benchmark and measure speed. Once you have learned that, you will find that the function is extremely fast - so much so that the time is negligible compared to the time it takes a JavaScript engine to call a function. > > My function: > > Use smallest possible time, create digit of it. Make 10 digit number of it. > Use function 2^a1+3^a2+...+11^a10 to create next digit with suming it until 1 digit. Function should always remember a2,...,a10, which will be next a1,...,a9. When the function is called in the same second(smallest clock unit usually), then increase a reminder variable digit when function is called again. When not, use next time produced digit as next a10. > > If it is already made, then please give me references. > Making a good random number generator is not easy. It is hard to make it at least reasonably random, and hard to make it efficient. You are not qualified to do either - it takes a lot of mathematical knowledge and experience, as well as solid understanding of low-level coding. It can be fun to /try/ to make a random number generator, and you can learn a lot from experimenting and playing around. But don't kid yourself that /you/ can do something better than the standard library in JavaScript (or any other language). Maybe one day you will reach that level, but it's twenty years down the road at least. Learn to benchmark and to experiment.
Back to comp.programming | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Increasing random() function speed. H e <he12457@hotmail.com> - 2021-01-18 03:07 -0800
Re: Increasing random() function speed. David Brown <david.brown@hesbynett.no> - 2021-01-18 12:15 +0100
Re: Increasing random() function speed. H E <kpuctjanpobam@mail.com> - 2021-01-18 06:41 -0800
Re: Increasing random() function speed. H E <kpuctjanpobam@mail.com> - 2021-01-18 06:42 -0800
Re: Increasing random() function speed. H E <kpuctjanpobam@mail.com> - 2021-01-18 06:45 -0800
Re: Increasing random() function speed. David Brown <david.brown@hesbynett.no> - 2021-01-18 16:14 +0100
Re: Increasing random() function speed. H e <he12457@hotmail.com> - 2021-01-18 10:29 -0800
csiph-web