Re: Create a string with (n) copies of the same character
- From: "Evertjan." <exjxw.hannivoort@xxxxxxxxxxxx>
- Date: 21 Sep 2007 07:35:10 GMT
Dr J R Stockton wrote on 20 sep 2007 in
microsoft.public.scripting.jscript:
function BigCat(L) {
if (!L) return ""
if (L&1) return BigCat(L-1) + "x"
var T = BigCat(L/2) ; return T + T }
what about:
L>>1
for
L/2
?
In itself it seems to be at least 3 times as fast:
==================================
<script type='text/javascript'>
function f1(n){
for (var i=0;i<n;i++)
z = 555550/2
};
function f2(n){
for (var i=0;i<n;i++)
z = 555550>>1
};
function f3(n){
for (var i=0;i<n;i++)
z = 7
};
var n = 600000
var t = new Date();
f3(n);
var overhead = new Date()-t
t = new Date();
f1(n);
document.write( new Date()-t-overhead + '<br>');
t = new Date();
f2(n);
document.write( new Date()-t-overhead + '<br>');
</script>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
.
- Follow-Ups:
- Re: Create a string with (n) copies of the same character
- From: Dr J R Stockton
- Re: Create a string with (n) copies of the same character
- References:
- Create a string with (n) copies of the same character
- From: \(O\)enone
- Re: Create a string with (n) copies of the same character
- From: Evertjan.
- Re: Create a string with (n) copies of the same character
- From: Evertjan.
- Re: Create a string with (n) copies of the same character
- From: Dr J R Stockton
- Create a string with (n) copies of the same character
- Prev by Date: Re: Create a string with (n) copies of the same character
- Next by Date: Re: Create a string with (n) copies of the same character
- Previous by thread: Re: Create a string with (n) copies of the same character
- Next by thread: Re: Create a string with (n) copies of the same character
- Index(es):
Relevant Pages
|
Loading