Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming > #11812 > unrolled thread

Fast randomizer

Started byH e <he12457@hotmail.com>
First post2021-01-17 12:59 -0800
Last post2022-01-05 00:39 -0800
Articles 20 on this page of 27 — 6 participants

Back to article view | Back to comp.programming


Contents

  Fast randomizer H e <he12457@hotmail.com> - 2021-01-17 12:59 -0800
    Re: Fast randomizer Tavis Ormandy <taviso@gmail.com> - 2021-01-17 21:11 +0000
      Re: Fast randomizer H e <he12457@hotmail.com> - 2021-01-17 13:26 -0800
        Re: Fast randomizer H e <he12457@hotmail.com> - 2021-01-17 14:01 -0800
        Re: Fast randomizer H e <he12457@hotmail.com> - 2021-01-17 14:13 -0800
          Re: Fast randomizer David Brown <david.brown@hesbynett.no> - 2021-01-18 00:09 +0100
            Re: Fast randomizer H e <he12457@hotmail.com> - 2021-01-17 16:53 -0800
              Re: Fast randomizer Richard Heathfield <rjh@cpax.org.uk> - 2021-01-18 07:30 +0000
                Re: Fast randomizer David Brown <david.brown@hesbynett.no> - 2021-01-18 08:55 +0100
                  Re: Fast randomizer Richard Heathfield <rjh@cpax.org.uk> - 2021-01-18 08:05 +0000
              Re: Fast randomizer David Brown <david.brown@hesbynett.no> - 2021-01-18 08:47 +0100
                Re: Fast randomizer H e <he12457@hotmail.com> - 2021-01-18 03:08 -0800
                  Re: Fast randomizer H e <he12457@hotmail.com> - 2021-01-18 03:18 -0800
                  Re: Fast randomizer David Brown <david.brown@hesbynett.no> - 2021-01-18 12:19 +0100
                    Re: Fast randomizer Julio Di Egidio <julio@diegidio.name> - 2022-01-05 02:56 -0800
                      Re: Fast randomizer Richard Heathfield <rjh@cpax.org.uk> - 2022-01-05 11:27 +0000
                        Re: Fast randomizer David Brown <david.brown@hesbynett.no> - 2022-01-05 16:00 +0100
                          Re: Fast randomizer Richard Heathfield <rjh@cpax.org.uk> - 2022-01-05 16:35 +0000
                        Re: Fast randomizer Julio Di Egidio <julio@diegidio.name> - 2022-01-05 14:23 -0800
                          Re: Fast randomizer David Brown <david.brown@hesbynett.no> - 2022-01-05 23:36 +0100
                            Re: Fast randomizer Julio Di Egidio <julio@diegidio.name> - 2022-01-05 14:41 -0800
                              Re: Fast randomizer Richard Heathfield <rjh@cpax.org.uk> - 2022-01-06 00:32 +0000
                                Re: Fast randomizer Julio Di Egidio <julio@diegidio.name> - 2022-01-06 01:21 -0800
                                  Re: Fast randomizer Richard Heathfield <rjh@cpax.org.uk> - 2022-01-06 09:38 +0000
                                    Re: Fast randomizer Julio Di Egidio <julio@diegidio.name> - 2022-01-06 01:48 -0800
                          Re: Fast randomizer Richard Heathfield <rjh@cpax.org.uk> - 2022-01-06 00:24 +0000
      Re: Fast randomizer Härra Ramob <ya12983@mail.com> - 2022-01-05 00:39 -0800

Page 1 of 2  [1] 2  Next page →


#11812 — Fast randomizer

FromH e <he12457@hotmail.com>
Date2021-01-17 12:59 -0800
SubjectFast randomizer
Message-ID<4d7dea01-65a4-422e-84ba-ad54b9d09615n@googlegroups.com>
Anybody knows why Javascript Math.random() is so slow?
Am the only one, who thinks, that it can be as fast as a computer screen?

What I am referring:
Take a time of Jesus Christ's birth.
Use a polynom(x^a1+x^a2+x^a3+x^a4+...+x^a10) from it(if integer is smaller than 10 digits - then make it to 10 digit with ^2(as many as you need))
Use a variable of minimum programming language time, when creating next polynom. The polynom will sum it's digits until it will get 1 digit integer.
It will be the next a10. Function will remember a2,...,a10. Next polynom takes as last polynom multiplier new time produced digit.



He

(372) 6861327










He

(372) 6861327

[toc] | [next] | [standalone]


#11814

FromTavis Ormandy <taviso@gmail.com>
Date2021-01-17 21:11 +0000
Message-ID<i6jnghF2s7kU1@mid.individual.net>
In reply to#11812
On 2021-01-17, H e <he12457@hotmail.com> wrote:
> Anybody knows why Javascript Math.random() is so slow?
> Am the only one, who thinks, that it can be as fast as a computer screen?
>

Which implementation? As far as I know, all major implementations use
xorshift128+, which is very fast with a very impressive period,
2^128-1. It is just a dozen or so machine instructions on a 64bit
machine.

You can read about it here: http://vigna.di.unimi.it/ftp/papers/xorshiftplus.pdf

> It will be the next a10. Function will remember a2,...,a10. Next
> polynom takes as last polynom multiplier new time produced digit.

I would suggest implementing your scheme and see if it passes the
Diehard test suite. If it does, then see if you can benchmark better
than something from the xorshift family with a similar period.

(I really think that is a tall order though)

https://en.wikipedia.org/wiki/Diehard_tests

Tavis.

-- 
 _o)            $ lynx lock.cmpxchg8b.com
 /\\  _o)  _o)  $ finger taviso@sdf.org
_\_V _( ) _( )  @taviso

[toc] | [prev] | [next] | [standalone]


#11816

FromH e <he12457@hotmail.com>
Date2021-01-17 13:26 -0800
Message-ID<0ace59de-aecc-4ac8-ae40-b9394a913fc4n@googlegroups.com>
In reply to#11814
Tavis Ormandy kirjutas pühapäev, 17. jaanuar 2021 kl 23:11:49 UTC+2:
> On 2021-01-17, H e <he1...@hotmail.com> wrote: 
> > Anybody knows why Javascript Math.random() is so slow? 
> > Am the only one, who thinks, that it can be as fast as a computer screen? 
> > 
> 
> Which implementation? As far as I know, all major implementations use 
> xorshift128+, which is very fast with a very impressive period, 
> 2^128-1. It is just a dozen or so machine instructions on a 64bit 
> machine. 
> 
> You can read about it here: http://vigna.di.unimi.it/ftp/papers/xorshiftplus.pdf 
> 
> > It will be the next a10. Function will remember a2,...,a10. Next 
> > polynom takes as last polynom multiplier new time produced digit. 
> 
> I would suggest implementing your scheme and see if it passes the 
> Diehard test suite. If it does, then see if you can benchmark better 
> than something from the xorshift family with a similar period. 
> 
> (I really think that is a tall order though) 
> 
> https://en.wikipedia.org/wiki/Diehard_tests 
> 
> Tavis. 
> 
> -- 
> _o) $ lynx lock.cmpxchg8b.com 
> /\\ _o) _o) $ finger tav...@sdf.org 
> _\_V _( ) _( ) @taviso

I am referring to Vivaldi in Manjaro linux. I am now using "Min". Have not tested this in that so far. Will look.



He

(372) 6861327

[toc] | [prev] | [next] | [standalone]


#11818

FromH e <he12457@hotmail.com>
Date2021-01-17 14:01 -0800
Message-ID<bc921128-a931-4c74-9004-f8bf8583a4d6n@googlegroups.com>
In reply to#11816
H e kirjutas pühapäev, 17. jaanuar 2021 kl 23:26:32 UTC+2:
> Tavis Ormandy kirjutas pühapäev, 17. jaanuar 2021 kl 23:11:49 UTC+2: 
> > On 2021-01-17, H e <he1...@hotmail.com> wrote: 
> > > Anybody knows why Javascript Math.random() is so slow? 
> > > Am the only one, who thinks, that it can be as fast as a computer screen? 
> > > 
> > 
> > Which implementation? As far as I know, all major implementations use 
> > xorshift128+, which is very fast with a very impressive period, 
> > 2^128-1. It is just a dozen or so machine instructions on a 64bit 
> > machine. 
> > 
> > You can read about it here: http://vigna.di.unimi.it/ftp/papers/xorshiftplus.pdf 
> > 
> > > It will be the next a10. Function will remember a2,...,a10. Next 
> > > polynom takes as last polynom multiplier new time produced digit. 
> > 
> > I would suggest implementing your scheme and see if it passes the 
> > Diehard test suite. If it does, then see if you can benchmark better 
> > than something from the xorshift family with a similar period. 
> > 
> > (I really think that is a tall order though) 
> > 
> > https://en.wikipedia.org/wiki/Diehard_tests 
> > 
> > Tavis. 
> > 
> > -- 
> > _o) $ lynx lock.cmpxchg8b.com 
> > /\\ _o) _o) $ finger tav...@sdf.org 
> > _\_V _( ) _( ) @taviso
> I am referring to Vivaldi in Manjaro linux. I am now using "Min". Have not tested this in that so far. Will look. 
> 
> 
> 
> He 
> 
> (372) 6861327


Seems a bit faster in Min.
The code I am referring to:

<html>
<head>
<style>
body {
height: 100%;
color:green;
background-color: black;
}
#a1 {
width: 105%;
height: 94%;
font-size: 2vw;
font-weight: bold;
overflow-y:hidden;
line-height:2vw;
margin-top:1%;
}
</style>
</head>
<body>

<div id="a1">
</div>
<script>
function a2() {
setInterval(function(){
var a01=document.getElementById("a1").innerHTML;
a01="</p>"+a01;
for(var i=0; i<10; i++) {
var a=Math.round(Math.random()*999999999);
a01=a+" "+a01;
}
a01="<p style='height:1px;'>"+a01;
document.getElementById("a1").innerHTML=a01;

var a=document.getElementById("a1").innerHTML;
if(a.length>3345) {
  var select = document.getElementById('a1');
  select.removeChild(select.lastChild);
}
}, 1);
}

a2();
</script>
</body>
</html>


Can You tell me how fast it is exactly ?
Is is the minimum programming language countable time unit ?





He
(372) 6861327

[toc] | [prev] | [next] | [standalone]


#11820

FromH e <he12457@hotmail.com>
Date2021-01-17 14:13 -0800
Message-ID<72f1bfaa-a97c-4bec-a999-c7ebdb6b4d3fn@googlegroups.com>
In reply to#11816
Seems a bit faster in Min.
The code I am referring to:

<html>
<head>
<style>
body {
height: 100%;
color:green;
background-color: black;
}
#a1 {
width: 105%;
height: 94%;
font-size: 2vw;
font-weight: bold;
overflow-y:hidden;
line-height:2vw;
margin-top:1%;
}
</style>
</head>
<body>

<div id="a1">
</div>
<script>
function a2() {
setInterval(function(){
var a01=document.getElementById("a1").innerHTML;
a01="</p>"+a01;
for(var i=0; i<10; i++) {
var a=Math.round(Math.random()*999999999);
a01=a+" "+a01;
}
a01="<p style='height:1px;'>"+a01;
document.getElementById("a1").innerHTML=a01;

var a=document.getElementById("a1").innerHTML;
if(a.length>3345) {
var select = document.getElementById('a1');
select.removeChild(select.lastChild);
}
}, 1);
}

a2();
</script>
</body>
</html>


Can You tell me how fast it is exactly ?
Is it the minimum programming language countable time unit ?





He
(372) 6861327

[toc] | [prev] | [next] | [standalone]


#11821

FromDavid Brown <david.brown@hesbynett.no>
Date2021-01-18 00:09 +0100
Message-ID<ru2g36$3ge$1@dont-email.me>
In reply to#11820
On 17/01/2021 23:13, H e wrote:
> Seems a bit faster in Min.

(This is your chance to be viewed as serious about learning to program.
 Think, and reply carefully, and you have a chance to learn something
useful.  Continue to post the verbal diarrhoea that you've done so far
in this group, and you'll lose that chance.)


What do you think you are testing, using the code you posted?  How do
you think it is affected by the speed of the Math.random() function?

[toc] | [prev] | [next] | [standalone]


#11824

FromH e <he12457@hotmail.com>
Date2021-01-17 16:53 -0800
Message-ID<39288c53-9bbf-4c3b-96e6-f2b93991497dn@googlegroups.com>
In reply to#11821
David Brown kirjutas esmaspäev, 18. jaanuar 2021 kl 01:09:30 UTC+2:
> On 17/01/2021 23:13, H e wrote: 
> > Seems a bit faster in Min.
> (This is your chance to be viewed as serious about learning to program. 
> Think, and reply carefully, and you have a chance to learn something 
> useful. Continue to post the verbal diarrhoea that you've done so far 
> in this group, and you'll lose that chance.) 
> 
> 
> What do you think you are testing, using the code you posted? How do 
> you think it is affected by the speed of the Math.random() function?

Hello dear David.
I am testing random() speed.
I am referring to the fact, that it should be as fast as a pc can operate.

Look this:
https://groups.google.com/g/comp.programming/c/omwgnEPXjhA




Mina, jah mina, kes küll muu.

(372) 6861327

[toc] | [prev] | [next] | [standalone]


#11825

FromRichard Heathfield <rjh@cpax.org.uk>
Date2021-01-18 07:30 +0000
Message-ID<ru3de4$j26$1@dont-email.me>
In reply to#11824
On 18/01/2021 00:53, H e wrote:
> David Brown kirjutas esmaspäev, 18. jaanuar 2021 kl 01:09:30 UTC+2:
>> On 17/01/2021 23:13, H e wrote:
>>> Seems a bit faster in Min.
>> (This is your chance to be viewed as serious about learning to program.
>> Think, and reply carefully, and you have a chance to learn something
>> useful. Continue to post the verbal diarrhoea that you've done so far
>> in this group, and you'll lose that chance.)
>>
>>
>> What do you think you are testing, using the code you posted? How do
>> you think it is affected by the speed of the Math.random() function?
> 
> Hello dear David.
> I am testing random() speed.

Perhaps, but you're posting scraps of source that David has rightly 
described as verbal diarrhoea.

He's not going to follow your links, any more than anyone else is - or 
at least, not until you've established that you're capable of holding a 
meaningful technical discussion, which so far you have not done.

-- 
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within

[toc] | [prev] | [next] | [standalone]


#11827

FromDavid Brown <david.brown@hesbynett.no>
Date2021-01-18 08:55 +0100
Message-ID<ru3eti$fmq$2@dont-email.me>
In reply to#11825
On 18/01/2021 08:30, Richard Heathfield wrote:
> On 18/01/2021 00:53, H e wrote:
>> David Brown kirjutas esmaspäev, 18. jaanuar 2021 kl 01:09:30 UTC+2:
>>> On 17/01/2021 23:13, H e wrote:
>>>> Seems a bit faster in Min.
>>> (This is your chance to be viewed as serious about learning to program.
>>> Think, and reply carefully, and you have a chance to learn something
>>> useful. Continue to post the verbal diarrhoea that you've done so far
>>> in this group, and you'll lose that chance.)
>>>
>>>
>>> What do you think you are testing, using the code you posted? How do
>>> you think it is affected by the speed of the Math.random() function?
>>
>> Hello dear David.
>> I am testing random() speed.
> 
> Perhaps, but you're posting scraps of source that David has rightly
> described as verbal diarrhoea.
> 
> He's not going to follow your links, any more than anyone else is - or
> at least, not until you've established that you're capable of holding a
> meaningful technical discussion, which so far you have not done.
> 

You are correct that I am not going to follow his links.  But I've given
him a leg-up on his testing, and we'll see where that leads.

[toc] | [prev] | [next] | [standalone]


#11828

FromRichard Heathfield <rjh@cpax.org.uk>
Date2021-01-18 08:05 +0000
Message-ID<ru3fg2$rt7$1@dont-email.me>
In reply to#11827
On 18/01/2021 07:55, David Brown wrote:
> On 18/01/2021 08:30, Richard Heathfield wrote:
>> On 18/01/2021 00:53, H e wrote:
>>> David Brown kirjutas esmaspäev, 18. jaanuar 2021 kl 01:09:30 UTC+2:
>>>> On 17/01/2021 23:13, H e wrote:
>>>>> Seems a bit faster in Min.
>>>> (This is your chance to be viewed as serious about learning to program.
>>>> Think, and reply carefully, and you have a chance to learn something
>>>> useful. Continue to post the verbal diarrhoea that you've done so far
>>>> in this group, and you'll lose that chance.)
>>>>
>>>>
>>>> What do you think you are testing, using the code you posted? How do
>>>> you think it is affected by the speed of the Math.random() function?
>>>
>>> Hello dear David.
>>> I am testing random() speed.
>>
>> Perhaps, but you're posting scraps of source that David has rightly
>> described as verbal diarrhoea.
>>
>> He's not going to follow your links, any more than anyone else is - or
>> at least, not until you've established that you're capable of holding a
>> meaningful technical discussion, which so far you have not done.
>>
> 
> You are correct that I am not going to follow his links.  But I've given
> him a leg-up on his testing, and we'll see where that leads.

Prediction:

Your code will give different results to the results he's already 
obtained. He will therefore wrongly dismiss your code as being 
incorrect, and will learn bugger all from the exercise.

My basis for this prediction is the ridiculous way he handled the 
cross-sum "discussion".

-- 
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within

[toc] | [prev] | [next] | [standalone]


#11826

FromDavid Brown <david.brown@hesbynett.no>
Date2021-01-18 08:47 +0100
Message-ID<ru3eeg$9ke$1@dont-email.me>
In reply to#11824
On 18/01/2021 01:53, H e wrote:
> David Brown kirjutas esmaspäev, 18. jaanuar 2021 kl 01:09:30 UTC+2:
>> On 17/01/2021 23:13, H e wrote: 
>>> Seems a bit faster in Min.
>> (This is your chance to be viewed as serious about learning to program. 
>> Think, and reply carefully, and you have a chance to learn something 
>> useful. Continue to post the verbal diarrhoea that you've done so far 
>> in this group, and you'll lose that chance.) 
>>
>>
>> What do you think you are testing, using the code you posted? How do 
>> you think it is affected by the speed of the Math.random() function?
> 
> Hello dear David.
> I am testing random() speed.

No - that is what you /want/ to test, but it is certainly not what you
are doing with that code.

Try with code like this:


<!DOCTYPE html>
<html>
<body>

<h2>Timing of Math.random()</h2>

<p>EmptyTime: <span id = "EmptyTime">X</span></p>
<p>TotalTime: <span id = "TotalTime">X</span></p>
<p>RandTime: <span id = "RandTime">X</span></p>

<script>

const rounds = 1000000000;

var starttime = Date.now()
for (var i = 0; i < rounds; i++) {
	// Empty loop
}
var emptytime = Date.now() - starttime;

document.getElementById("EmptyTime").innerHTML =
  (1000000 * emptytime / rounds) + " µs";

starttime = Date.now()
for (var i = 0; i < rounds; i++) {
	var x = Math.random();
}
var totaltime = Date.now() - starttime;

document.getElementById("TotalTime").innerHTML =
  1000000 * (totaltime / rounds) + " µs";

var randtime = totaltime - emptytime;
document.getElementById("RandTime").innerHTML =
  1000000 * (randtime / rounds) + " µs";


</script>

</body>
</html>


Depending on the speed of your computer/browser, you may need to change
the value of "rounds".  The script should take a few seconds to run -
anything less and you have little accuracy in the results.  Ideally it
should run for minutes, but I didn't want to spend that long.

Now, let's compare my code with yours, and see what differences there are.

1. My code looks like program code, not line noise.  Learn to lay out
your code properly with indentation, and spacing in the code.
Readability is key to programming.  (If Richard is paying attention,
I'll let him quote you Heathfield's Law here.)  Use suitable identifier
names, even in the smallest of test code.  But don't fill the code with
pointless style stuff - if all you need out is some numbers, that's all
you make.

2. If you want to test the speed of something - like the Math.random()
function - then aim to test /only/ that.  Your code does rounding,
arithmetic, conversion to string, string concatenation - which will take
orders of magnitude longer than the call to Math.random(), completely
swamping its effect.

3. When testing the speed of a fast operation, you need to do it /many/
times.  Here I am looping 1,000,000,000 times.  You looped 10 times.
PC's, especially JavaScript environments, have a huge variability in
their timings depending on loads, dynamic clock speeds, JIT
optimisation, and all sorts of other factors.  To have a hope of even a
vaguely useful result, you need to average out over a huge number of
iterations.

4. The speed of the "for" loop itself could dominate.  (In my testing,
it was in fact roughly the same speed as the call to Math.random()
itself.)  So my code compensates for that.


So now you have a rough basis for doing some benchmarking that can give
at least vaguely realistic results, you do some more testing.  Things
you will want to check include :

1. Is Date.now() the best way of getting a good time reference?  (I
don't know, I am not a JavaScript expert.)

2. Is the timing stable enough, or can you do better?  Take multiple
samples and present a table or graph?

3. How does simply calling an empty function compare to calling
Math.round() ?  If it is similar, then Math.random() is already as fast
as it could be.

4. How does your own "random" function compare in timing?

[toc] | [prev] | [next] | [standalone]


#11831

FromH e <he12457@hotmail.com>
Date2021-01-18 03:08 -0800
Message-ID<137c1d41-e746-4835-9dda-8ca5dc4002adn@googlegroups.com>
In reply to#11826
David Brown kirjutas esmaspäev, 18. jaanuar 2021 kl 09:49:28 UTC+2:
> On 18/01/2021 01:53, H e wrote: 
> > David Brown kirjutas esmaspäev, 18. jaanuar 2021 kl 01:09:30 UTC+2: 
> >> On 17/01/2021 23:13, H e wrote: 
> >>> Seems a bit faster in Min. 
> >> (This is your chance to be viewed as serious about learning to program. 
> >> Think, and reply carefully, and you have a chance to learn something 
> >> useful. Continue to post the verbal diarrhoea that you've done so far 
> >> in this group, and you'll lose that chance.) 
> >> 
> >> 
> >> What do you think you are testing, using the code you posted? How do 
> >> you think it is affected by the speed of the Math.random() function? 
> > 
> > Hello dear David. 
> > I am testing random() speed.
> No - that is what you /want/ to test, but it is certainly not what you 
> are doing with that code. 
> 
> Try with code like this: 
> 
> 
> <!DOCTYPE html> 
> <html> 
> <body> 
> 
> <h2>Timing of Math.random()</h2> 
> 
> <p>EmptyTime: <span id = "EmptyTime">X</span></p> 
> <p>TotalTime: <span id = "TotalTime">X</span></p> 
> <p>RandTime: <span id = "RandTime">X</span></p> 
> 
> <script> 
> 
> const rounds = 1000000000; 
> 
> var starttime = Date.now() 
> for (var i = 0; i < rounds; i++) { 
> // Empty loop 
> } 
> var emptytime = Date.now() - starttime; 
> 
> document.getElementById("EmptyTime").innerHTML = 
> (1000000 * emptytime / rounds) + " µs"; 
> 
> starttime = Date.now() 
> for (var i = 0; i < rounds; i++) { 
> var x = Math.random(); 
> } 
> var totaltime = Date.now() - starttime; 
> 
> document.getElementById("TotalTime").innerHTML = 
> 1000000 * (totaltime / rounds) + " µs"; 
> 
> var randtime = totaltime - emptytime; 
> document.getElementById("RandTime").innerHTML = 
> 1000000 * (randtime / rounds) + " µs"; 
> 
> 
> </script> 
> 
> </body> 
> </html> 
> 
> 
> Depending on the speed of your computer/browser, you may need to change 
> the value of "rounds". The script should take a few seconds to run - 
> anything less and you have little accuracy in the results. Ideally it 
> should run for minutes, but I didn't want to spend that long. 
> 
> Now, let's compare my code with yours, and see what differences there are. 
> 
> 1. My code looks like program code, not line noise. Learn to lay out 
> your code properly with indentation, and spacing in the code. 
> Readability is key to programming. (If Richard is paying attention, 
> I'll let him quote you Heathfield's Law here.) Use suitable identifier 
> names, even in the smallest of test code. But don't fill the code with 
> pointless style stuff - if all you need out is some numbers, that's all 
> you make. 
> 
> 2. If you want to test the speed of something - like the Math.random() 
> function - then aim to test /only/ that. Your code does rounding, 
> arithmetic, conversion to string, string concatenation - which will take 
> orders of magnitude longer than the call to Math.random(), completely 
> swamping its effect. 
> 
> 3. When testing the speed of a fast operation, you need to do it /many/ 
> times. Here I am looping 1,000,000,000 times. You looped 10 times. 
> PC's, especially JavaScript environments, have a huge variability in 
> their timings depending on loads, dynamic clock speeds, JIT 
> optimisation, and all sorts of other factors. To have a hope of even a 
> vaguely useful result, you need to average out over a huge number of 
> iterations. 
> 
> 4. The speed of the "for" loop itself could dominate. (In my testing, 
> it was in fact roughly the same speed as the call to Math.random() 
> itself.) So my code compensates for that. 
> 
> 
> So now you have a rough basis for doing some benchmarking that can give 
> at least vaguely realistic results, you do some more testing. Things 
> you will want to check include : 
> 
> 1. Is Date.now() the best way of getting a good time reference? (I 
> don't know, I am not a JavaScript expert.) 
> 
> 2. Is the timing stable enough, or can you do better? Take multiple 
> samples and present a table or graph? 
> 
> 3. How does simply calling an empty function compare to calling 
> Math.round() ? If it is similar, then Math.random() is already as fast 
> as it could be. 
> 
> 4. How does your own "random" function compare in timing?

This code does not work in my browser.





He

372(country code) 6861327

[toc] | [prev] | [next] | [standalone]


#11833

FromH e <he12457@hotmail.com>
Date2021-01-18 03:18 -0800
Message-ID<b8a00758-7009-488b-96db-c8e6f8229f3dn@googlegroups.com>
In reply to#11831
Guys, look my new function for it:
https://groups.google.com/g/comp.programming/c/jAWV0arcuEY

The testing html with smaller font:

<html>
<head>
<style>
body {
height: 100%;
color:#ff99ff;
background-color: white;
}
#a1 {
width: 100%;
height: 100%;
font-size: 0.9vw;
font-weight: bold;
font-style: italic;
overflow-y:hidden;
line-height:2vw;
margin-top:-3vh;
}
</style>
</head>
<body>

<div id="a1">
</div>
<script>
function a2() {
setInterval(function(){
var a01=document.getElementById("a1").innerHTML;
a01="</p>"+a01;
for(var i=0; i<23; i++) {
var a=Math.round(Math.random()*999999999);
a01=a+" "+a01;
}
a01="<p style='height:1px;'>"+a01;
document.getElementById("a1").innerHTML=a01;

var a=document.getElementById("a1").innerHTML;
if(a.length>12245) {
  var select = document.getElementById('a1');
  select.removeChild(select.lastChild);
}
}, 1);
}

a2();
</script>
</body>
</html>


He

Tel.: 372(country code) 6861327

[toc] | [prev] | [next] | [standalone]


#11834

FromDavid Brown <david.brown@hesbynett.no>
Date2021-01-18 12:19 +0100
Message-ID<ru3qrf$k4c$1@dont-email.me>
In reply to#11831
On 18/01/2021 12:08, H e wrote:

> This code does not work in my browser.
> 

That is one of the reasons why no one considers JavaScript to be a
serious programming language - there are far too many variations of it
and far too many inconsistent implementations.

You are trying to learn the basics of programming and software
development.  Take the code I posted, and try to find out /why/ it
doesn't work on your browser - and how to change it to make it work.

Oh, and if you intend to use Usenet, please get yourself a newsreader
program (Thunderbird is fine for most people) and a newsserver
(news.eternal-september.org is popular and free), and drop the crappy
"google groups" interface.  The limitations of google groups show up
quickly when trying to post code.

[toc] | [prev] | [next] | [standalone]


#14439

FromJulio Di Egidio <julio@diegidio.name>
Date2022-01-05 02:56 -0800
Message-ID<7e00c242-1cc9-409c-8505-0419ccb0d303n@googlegroups.com>
In reply to#11834
On Monday, 18 January 2021 at 12:19:15 UTC+1, David Brown wrote:
> On 18/01/2021 12:08, H e wrote: 
> 
> > This code does not work in my browser. 
> >
> That is one of the reasons why no one considers JavaScript to be a 
> serious programming language - there are far too many variations of it 
> and far too many inconsistent implementations. 

It is you who are an incompetent fucking clown just repeating some bullshit you read in the blogs.

JS, "the world's most misunderstood programming language", indeed is a *wonderful* language (modulo the pseudo-OO bullshit they have been adding to it thanks, again, to the ultimate morons who have been asking for it, but one can ignore that just stuff...)

> You are trying to learn the basics of programming and software 
> development. Take the code I posted, and try to find out /why/ it 
> doesn't work on your browser - and how to change it to make it work. 
> 
> Oh, and if you intend to use Usenet, please get yourself a newsreader 
> program (Thunderbird is fine for most people) and a newsserver 
> (news.eternal-september.org is popular and free), and drop the crappy 
> "google groups" interface. The limitations of google groups show up 
> quickly when trying to post code.

You are the measure of how fucking insane and inane humanity has become.  ESAD.

*Spammer Alert*

Julio

[toc] | [prev] | [next] | [standalone]


#14440

FromRichard Heathfield <rjh@cpax.org.uk>
Date2022-01-05 11:27 +0000
Message-ID<sr3vbu$fhh$1@dont-email.me>
In reply to#14439
On 05/01/2022 10:56, Julio Di Egidio wrote:
> On Monday, 18 January 2021 at 12:19:15 UTC+1, David Brown wrote:

<snip>

>> The limitations of google groups show up
>> quickly when trying to post code.
> 
> You are the measure of how fucking insane and inane humanity has become.  ESAD.
> 
> *Spammer Alert*

You plonked David *twice* less than a month ago. And here you are 
replying to him. The limitations of google groups show up quickly when 
trying to plonk someone, especially when he's right and you're wrong.

Here's a tip for you. If you want people to take you seriously, drop the 
swearing, which marks you out as an adolescent fool.

-- 
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within

[toc] | [prev] | [next] | [standalone]


#14441

FromDavid Brown <david.brown@hesbynett.no>
Date2022-01-05 16:00 +0100
Message-ID<sr4bqv$50m$1@dont-email.me>
In reply to#14440
On 05/01/2022 12:27, Richard Heathfield wrote:
> On 05/01/2022 10:56, Julio Di Egidio wrote:
>> On Monday, 18 January 2021 at 12:19:15 UTC+1, David Brown wrote:
> 
> <snip>
> 
>>> The limitations of google groups show up
>>> quickly when trying to post code.
>>
>> You are the measure of how fucking insane and inane humanity has
>> become.  ESAD.
>>
>> *Spammer Alert*
> 
> You plonked David *twice* less than a month ago. And here you are
> replying to him. The limitations of google groups show up quickly when
> trying to plonk someone, especially when he's right and you're wrong.
> 
> Here's a tip for you. If you want people to take you seriously, drop the
> swearing, which marks you out as an adolescent fool.
> 

He is also responding to a year-old post, which does not make him look
any better!

I can't figure out Julio - I wonder if it is two people using the same
account.  Sometimes he makes appropriate posts - polite enough and
on-topic for the threads, and generally contributing to this (and other)
newsgroups.  And sometimes he makes posts that are just random swearing
and accusations of spamming.

I've had a few people plonk me over the years, as the result of
long-standing disagreements or character clashes - that's fair enough.
Anyone is free to read my posts and free to ignore them.  But I have
never spam-posted, and his "plonk" posts came out of the blue.

And I can't imagine any justification someone could have for plonking
/you/, or Ben - as Julio has claimed to do.

Well, I guess we've all met stranger characters on Usenet!


[toc] | [prev] | [next] | [standalone]


#14443

FromRichard Heathfield <rjh@cpax.org.uk>
Date2022-01-05 16:35 +0000
Message-ID<sr4hd2$gpu$1@dont-email.me>
In reply to#14441
On 05/01/2022 15:00, David Brown wrote:
> Well, I guess we've all met stranger characters on Usenet!

Truly it has been said: Usenet is a strange place.

-- 
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within

[toc] | [prev] | [next] | [standalone]


#14448

FromJulio Di Egidio <julio@diegidio.name>
Date2022-01-05 14:23 -0800
Message-ID<5533677b-9682-4454-b15e-9aeecc69095en@googlegroups.com>
In reply to#14440
On Wednesday, 5 January 2022 at 12:28:02 UTC+1, Richard Heathfield wrote:
> On 05/01/2022 10:56, Julio Di Egidio wrote: 
> > On Monday, 18 January 2021 at 12:19:15 UTC+1, David Brown wrote:
> <snip>
> >> The limitations of google groups show up 
> >> quickly when trying to post code. 
> > 
> > You are the measure of how fucking insane and inane humanity has become. ESAD. 
> > 
> > *Spammer Alert*
> 
> You plonked David *twice* less than a month ago.

And I'll keep doing it, you other piece of resident spamming shit: not for his sake of course, I have given up on you headless cunts.

ESAD, both of you.

*Plonk*

Julio

[toc] | [prev] | [next] | [standalone]


#14450

FromDavid Brown <david.brown@hesbynett.no>
Date2022-01-05 23:36 +0100
Message-ID<sr56hl$iqa$1@dont-email.me>
In reply to#14448
On 05/01/2022 23:23, Julio Di Egidio wrote:
> On Wednesday, 5 January 2022 at 12:28:02 UTC+1, Richard Heathfield wrote:
>> On 05/01/2022 10:56, Julio Di Egidio wrote: 
>>> On Monday, 18 January 2021 at 12:19:15 UTC+1, David Brown wrote:
>> <snip>
>>>> The limitations of google groups show up 
>>>> quickly when trying to post code. 
>>>
>>> You are the measure of how fucking insane and inane humanity has become. ESAD. 
>>>
>>> *Spammer Alert*
>>
>> You plonked David *twice* less than a month ago.
> 
> And I'll keep doing it, you other piece of resident spamming shit: not for his sake of course, I have given up on you headless cunts.
> 
> ESAD, both of you.
> 
> *Plonk*
> 

Do you actually know what the term "plonk" means here?  It seems more
likely that you are just an ignorant plonker.


(Apologies to any non-British people here, who may not know the slang
term "plonker".)

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | comp.programming


csiph-web