Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #32596 > unrolled thread
| Started by | jonas.thornvall@gmail.com |
|---|---|
| First post | 2017-02-10 09:49 -0800 |
| Last post | 2017-02-10 21:38 -0800 |
| Articles | 11 — 2 participants |
Back to article view | Back to comp.lang.javascript
Optional code to execute in loop? jonas.thornvall@gmail.com - 2017-02-10 09:49 -0800
Re: Optional code to execute in loop? jonas.thornvall@gmail.com - 2017-02-10 09:53 -0800
Re: Optional code to execute in loop? jonas.thornvall@gmail.com - 2017-02-10 09:55 -0800
Re: Optional code to execute in loop? jonas.thornvall@gmail.com - 2017-02-10 10:19 -0800
Re: Optional code to execute in loop? Gene Wirchenko <genew@telus.net> - 2017-02-10 13:54 -0800
Re: Optional code to execute in loop? jonas.thornvall@gmail.com - 2017-02-10 19:46 -0800
Re: Optional code to execute in loop? jonas.thornvall@gmail.com - 2017-02-10 19:56 -0800
Re: Optional code to execute in loop? jonas.thornvall@gmail.com - 2017-02-10 20:11 -0800
Re: Optional code to execute in loop? jonas.thornvall@gmail.com - 2017-02-10 20:24 -0800
Re: Optional code to execute in loop? jonas.thornvall@gmail.com - 2017-02-10 20:49 -0800
Re: Optional code to execute in loop? jonas.thornvall@gmail.com - 2017-02-10 21:38 -0800
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2017-02-10 09:49 -0800 |
| Subject | Optional code to execute in loop? |
| Message-ID | <200390cb-0ecc-4e01-979c-c1ad09506073@googlegroups.com> |
I draw out graphic and sometime i want optional data upon the lineart, but not always, redraw does call the animation every x millisec, i really do not want multiple loops because that effect the performance? So can you have if statement within a loop that is not checked again and again but just once? Yeah i know it sounds ridiculous, it sounds like a different programming paradigm. But people must be dealing with this kind of issues when writing out big sets of data that sometimes they want the exra info/data and somtimes omitted.
[toc] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2017-02-10 09:53 -0800 |
| Message-ID | <e36e805f-0bfd-4528-ab29-876dddbd31dc@googlegroups.com> |
| In reply to | #32596 |
Den fredag 10 februari 2017 kl. 18:49:50 UTC+1 skrev jonas.t...@gmail.com: > I draw out graphic and sometime i want optional data upon the lineart, but not always, redraw does call the animation every x millisec, i really do not want multiple loops because that effect the performance? > > So can you have if statement within a loop that is not checked again and again but just once? > > Yeah i know it sounds ridiculous, it sounds like a different programming paradigm. > > But people must be dealing with this kind of issues when writing out big sets of data that sometimes they want the exra info/data and somtimes omitted. Well i considered make two versions, but it seem a bit stupid but maybe that is the only way?
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2017-02-10 09:55 -0800 |
| Message-ID | <bedeca21-d828-472d-9f0a-db538fd653cb@googlegroups.com> |
| In reply to | #32596 |
Den fredag 10 februari 2017 kl. 18:49:50 UTC+1 skrev jonas.t...@gmail.com: > I draw out graphic and sometime i want optional data upon the lineart, but not always, redraw does call the animation every x millisec, i really do not want multiple loops because that effect the performance? > > So can you have if statement within a loop that is not checked again and again but just once? > > Yeah i know it sounds ridiculous, it sounds like a different programming paradigm. > > But people must be dealing with this kind of issues when writing out big sets of data that sometimes they want the exra info/data and somtimes omitted. Actually it would be 3 versions and so on for every optional data you want, and their combinations, i think it is weird programming languages do not have built in functionality to handle cases? Or is there a way to omit different set of information in javascripts loops?
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2017-02-10 10:19 -0800 |
| Message-ID | <5bfa8355-d4b5-47d6-b326-69a9ed0759cf@googlegroups.com> |
| In reply to | #32598 |
Den fredag 10 februari 2017 kl. 18:55:51 UTC+1 skrev jonas.t...@gmail.com: > Den fredag 10 februari 2017 kl. 18:49:50 UTC+1 skrev jonas.t...@gmail.com: > > I draw out graphic and sometime i want optional data upon the lineart, but not always, redraw does call the animation every x millisec, i really do not want multiple loops because that effect the performance? > > > > So can you have if statement within a loop that is not checked again and again but just once? > > > > Yeah i know it sounds ridiculous, it sounds like a different programming paradigm. > > > > But people must be dealing with this kind of issues when writing out big sets of data that sometimes they want the exra info/data and somtimes omitted. > > Actually it would be 3 versions and so on for every optional data you want, and their combinations, i think it is weird programming languages do not have built in functionality to handle cases? > > Or is there a way to omit different set of information in javascripts loops? Before hardware CGI and gpu era how did people handle select write out wireframe and switch to polygon mesh? Maybe it was totally different routines? But there must be cases even with large bulk transactions where speed requirements, how to the handle optional data in loops? It seem weird to check again and again once you concluded it should or should not be written out.
[toc] | [prev] | [next] | [standalone]
| From | Gene Wirchenko <genew@telus.net> |
|---|---|
| Date | 2017-02-10 13:54 -0800 |
| Message-ID | <o8ds9cpacan4pp1ttmbs37lbdqcqvqq8q1@4ax.com> |
| In reply to | #32599 |
On Fri, 10 Feb 2017 10:19:34 -0800 (PST), jonas.thornvall@gmail.com
wrote:
>Den fredag 10 februari 2017 kl. 18:55:51 UTC+1 skrev jonas.t...@gmail.com:
>> Den fredag 10 februari 2017 kl. 18:49:50 UTC+1 skrev jonas.t...@gmail.com:
>> > I draw out graphic and sometime i want optional data upon the
lineart, but not always, redraw does call the animation every x
millisec, i really do not want multiple loops because that effect the
performance?
>> >
>> > So can you have if statement within a loop that is not checked
again and again but just once?
>> >
>> > Yeah i know it sounds ridiculous, it sounds like a different
programming paradigm.
>> >
>> > But people must be dealing with this kind of issues when writing
out big sets of data that sometimes they want the exra info/data and
somtimes omitted.
>>
>> Actually it would be 3 versions and so on for every optional data
you want, and their combinations, i think it is weird programming
languages do not have built in functionality to handle cases?
>>
>> Or is there a way to omit different set of information in
javascripts loops?
>
>Before hardware CGI and gpu era how did people handle select write
out wireframe and switch to polygon mesh? Maybe it was totally
different routines?
>
>But there must be cases even with large bulk transactions where
speed requirements, how to the handle optional data in loops? It seem
weird to check again and again once you concluded it should or should
not be written out.
Speed is not usually as much of an issue as many people think.
Try benchmarking your code to see if it really needs the extra speed.
Use an if. You could write two versions:
if optionshouldberun()
for i=1 to numthings
requiredthing(i)
optionalthing(i)
else
for i=1 to numthings
requiredthing(i)
This gets nasty when you have a bunch of this and have to modify
your code so use it judiciously.
Sincerely,
Gene Wirchenko
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2017-02-10 19:46 -0800 |
| Message-ID | <223d8aca-d438-4b34-bdf4-2f5d9a816214@googlegroups.com> |
| In reply to | #32600 |
Den fredag 10 februari 2017 kl. 22:54:25 UTC+1 skrev Gene Wirchenko:
> On Fri, 10 Feb 2017 10:19:34 -0800 (PST), jonas.thornvall@gmail.com
> wrote:
>
> >Den fredag 10 februari 2017 kl. 18:55:51 UTC+1 skrev jonas.t...@gmail.com:
> >> Den fredag 10 februari 2017 kl. 18:49:50 UTC+1 skrev jonas.t...@gmail.com:
> >> > I draw out graphic and sometime i want optional data upon the
> lineart, but not always, redraw does call the animation every x
> millisec, i really do not want multiple loops because that effect the
> performance?
> >> >
> >> > So can you have if statement within a loop that is not checked
> again and again but just once?
> >> >
> >> > Yeah i know it sounds ridiculous, it sounds like a different
> programming paradigm.
> >> >
> >> > But people must be dealing with this kind of issues when writing
> out big sets of data that sometimes they want the exra info/data and
> somtimes omitted.
> >>
> >> Actually it would be 3 versions and so on for every optional data
> you want, and their combinations, i think it is weird programming
> languages do not have built in functionality to handle cases?
> >>
> >> Or is there a way to omit different set of information in
> javascripts loops?
> >
> >Before hardware CGI and gpu era how did people handle select write
> out wireframe and switch to polygon mesh? Maybe it was totally
> different routines?
> >
> >But there must be cases even with large bulk transactions where
> speed requirements, how to the handle optional data in loops? It seem
> weird to check again and again once you concluded it should or should
> not be written out.
>
> Speed is not usually as much of an issue as many people think.
> Try benchmarking your code to see if it really needs the extra speed.
>
> Use an if. You could write two versions:
>
> if optionshouldberun()
> for i=1 to numthings
> requiredthing(i)
> optionalthing(i)
> else
> for i=1 to numthings
> requiredthing(i)
>
> This gets nasty when you have a bunch of this and have to modify
> your code so use it judiciously.
>
> Sincerely,
>
> Gene Wirchenko
I probably do things backward Gene, but right now my code poll a redraw every x millsec. This redraw function call paintOut. Now the cordinates used in paintOut is contantly changing.
So with your approach i remove polling? the conditions "met" for every recurring paintout.
But it still have to check for every redraw every x millisec.
Unless i move up the if condition and have two or more redraw routines.
Well it is so weird.
Is there languages with cases only run once inside loop?
like having a boolean handler to a codeblock if the conditions met the code will be run otherwise the codeblock omitted within loop?
Something like this?
boolCase1=true;
boolCase2=false;
boolCase3=true;
while(x<10,boolCase1, boolCase2, boolCase3){
boolCase1:
boolCase2: //This codeblock will be omitted because not true
boolCase3:
}
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2017-02-10 19:56 -0800 |
| Message-ID | <56408c51-836d-4e79-805c-789b39aba573@googlegroups.com> |
| In reply to | #32602 |
Den lördag 11 februari 2017 kl. 04:46:20 UTC+1 skrev jonas.t...@gmail.com:
> Den fredag 10 februari 2017 kl. 22:54:25 UTC+1 skrev Gene Wirchenko:
> > On Fri, 10 Feb 2017 10:19:34 -0800 (PST), jonas.thornvall@gmail.com
> > wrote:
> >
> > >Den fredag 10 februari 2017 kl. 18:55:51 UTC+1 skrev jonas.t...@gmail.com:
> > >> Den fredag 10 februari 2017 kl. 18:49:50 UTC+1 skrev jonas.t...@gmail.com:
> > >> > I draw out graphic and sometime i want optional data upon the
> > lineart, but not always, redraw does call the animation every x
> > millisec, i really do not want multiple loops because that effect the
> > performance?
> > >> >
> > >> > So can you have if statement within a loop that is not checked
> > again and again but just once?
> > >> >
> > >> > Yeah i know it sounds ridiculous, it sounds like a different
> > programming paradigm.
> > >> >
> > >> > But people must be dealing with this kind of issues when writing
> > out big sets of data that sometimes they want the exra info/data and
> > somtimes omitted.
> > >>
> > >> Actually it would be 3 versions and so on for every optional data
> > you want, and their combinations, i think it is weird programming
> > languages do not have built in functionality to handle cases?
> > >>
> > >> Or is there a way to omit different set of information in
> > javascripts loops?
> > >
> > >Before hardware CGI and gpu era how did people handle select write
> > out wireframe and switch to polygon mesh? Maybe it was totally
> > different routines?
> > >
> > >But there must be cases even with large bulk transactions where
> > speed requirements, how to the handle optional data in loops? It seem
> > weird to check again and again once you concluded it should or should
> > not be written out.
> >
> > Speed is not usually as much of an issue as many people think.
> > Try benchmarking your code to see if it really needs the extra speed.
> >
> > Use an if. You could write two versions:
> >
> > if optionshouldberun()
> > for i=1 to numthings
> > requiredthing(i)
> > optionalthing(i)
> > else
> > for i=1 to numthings
> > requiredthing(i)
> >
> > This gets nasty when you have a bunch of this and have to modify
> > your code so use it judiciously.
> >
> > Sincerely,
> >
> > Gene Wirchenko
>
> I probably do things backward Gene, but right now my code poll a redraw every x millsec. This redraw function call paintOut. Now the cordinates used in paintOut is contantly changing.
>
> So with your approach i remove polling? the conditions "met" for every recurring paintout.
>
> But it still have to check for every redraw every x millisec.
>
> Unless i move up the if condition and have two or more redraw routines.
> Well it is so weird.
>
> Is there languages with cases only run once inside loop?
> like having a boolean handler to a codeblock if the conditions met the code will be run otherwise the codeblock omitted within loop?
>
> Something like this?
> boolCase1=true;
> boolCase2=false;
> boolCase3=true;
> while(x<10,boolCase1, boolCase2, boolCase3){
> boolCase1:
> boolCase2: //This codeblock will be omitted because not true
> boolCase3:
> }
Well above seem a little redundant.
boolCase1=true;
boolCase2=false;
boolCase3=true;
boolCase1:{code here}
boolCase2:{code here}
boolCase3:{code here}
while(x<10,boolCase1, boolCase2, boolCase3);
or like this
boolCase1=true;
boolCase2=false;
boolCase3=true;
while(x<10){
boolCase1:{code here}
boolCase2:{code here}
boolCase3:{code here}
}
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2017-02-10 20:11 -0800 |
| Message-ID | <19f40891-93e8-4ae9-8eab-8442f8f80bbf@googlegroups.com> |
| In reply to | #32603 |
Den lördag 11 februari 2017 kl. 04:57:05 UTC+1 skrev jonas.t...@gmail.com:
> Den lördag 11 februari 2017 kl. 04:46:20 UTC+1 skrev jonas.t...@gmail.com:
> > Den fredag 10 februari 2017 kl. 22:54:25 UTC+1 skrev Gene Wirchenko:
> > > On Fri, 10 Feb 2017 10:19:34 -0800 (PST), jonas.thornvall@gmail.com
> > > wrote:
> > >
> > > >Den fredag 10 februari 2017 kl. 18:55:51 UTC+1 skrev jonas.t...@gmail.com:
> > > >> Den fredag 10 februari 2017 kl. 18:49:50 UTC+1 skrev jonas.t...@gmail.com:
> > > >> > I draw out graphic and sometime i want optional data upon the
> > > lineart, but not always, redraw does call the animation every x
> > > millisec, i really do not want multiple loops because that effect the
> > > performance?
> > > >> >
> > > >> > So can you have if statement within a loop that is not checked
> > > again and again but just once?
> > > >> >
> > > >> > Yeah i know it sounds ridiculous, it sounds like a different
> > > programming paradigm.
> > > >> >
> > > >> > But people must be dealing with this kind of issues when writing
> > > out big sets of data that sometimes they want the exra info/data and
> > > somtimes omitted.
> > > >>
> > > >> Actually it would be 3 versions and so on for every optional data
> > > you want, and their combinations, i think it is weird programming
> > > languages do not have built in functionality to handle cases?
> > > >>
> > > >> Or is there a way to omit different set of information in
> > > javascripts loops?
> > > >
> > > >Before hardware CGI and gpu era how did people handle select write
> > > out wireframe and switch to polygon mesh? Maybe it was totally
> > > different routines?
> > > >
> > > >But there must be cases even with large bulk transactions where
> > > speed requirements, how to the handle optional data in loops? It seem
> > > weird to check again and again once you concluded it should or should
> > > not be written out.
> > >
> > > Speed is not usually as much of an issue as many people think.
> > > Try benchmarking your code to see if it really needs the extra speed.
> > >
> > > Use an if. You could write two versions:
> > >
> > > if optionshouldberun()
> > > for i=1 to numthings
> > > requiredthing(i)
> > > optionalthing(i)
> > > else
> > > for i=1 to numthings
> > > requiredthing(i)
> > >
> > > This gets nasty when you have a bunch of this and have to modify
> > > your code so use it judiciously.
> > >
> > > Sincerely,
> > >
> > > Gene Wirchenko
> >
> > I probably do things backward Gene, but right now my code poll a redraw every x millsec. This redraw function call paintOut. Now the cordinates used in paintOut is contantly changing.
> >
> > So with your approach i remove polling? the conditions "met" for every recurring paintout.
> >
> > But it still have to check for every redraw every x millisec.
> >
> > Unless i move up the if condition and have two or more redraw routines.
> > Well it is so weird.
> >
> > Is there languages with cases only run once inside loop?
> > like having a boolean handler to a codeblock if the conditions met the code will be run otherwise the codeblock omitted within loop?
> >
> > Something like this?
> > boolCase1=true;
> > boolCase2=false;
> > boolCase3=true;
> > while(x<10,boolCase1, boolCase2, boolCase3){
> > boolCase1:
> > boolCase2: //This codeblock will be omitted because not true
> > boolCase3:
> > }
>
> Well above seem a little redundant.
>
> boolCase1=true;
> boolCase2=false;
> boolCase3=true;
> boolCase1:{code here}
> boolCase2:{code here}
> boolCase3:{code here}
> while(x<10,boolCase1, boolCase2, boolCase3);
>
> or like this
>
> boolCase1=true;
> boolCase2=false;
> boolCase3=true;
>
> while(x<10){
> boolCase1:{code here}
> boolCase2:{code here}
> boolCase3:{code here}
> }
But maybe this is considered to be ugly goto programming, but it seem rather straightforward, it really save some ugly fiddling?
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2017-02-10 20:24 -0800 |
| Message-ID | <0cb505b9-250d-49a9-8bba-2f475249c565@googlegroups.com> |
| In reply to | #32604 |
Den lördag 11 februari 2017 kl. 05:11:30 UTC+1 skrev jonas.t...@gmail.com:
> Den lördag 11 februari 2017 kl. 04:57:05 UTC+1 skrev jonas.t...@gmail.com:
> > Den lördag 11 februari 2017 kl. 04:46:20 UTC+1 skrev jonas.t...@gmail.com:
> > > Den fredag 10 februari 2017 kl. 22:54:25 UTC+1 skrev Gene Wirchenko:
> > > > On Fri, 10 Feb 2017 10:19:34 -0800 (PST), jonas.thornvall@gmail.com
> > > > wrote:
> > > >
> > > > >Den fredag 10 februari 2017 kl. 18:55:51 UTC+1 skrev jonas.t...@gmail.com:
> > > > >> Den fredag 10 februari 2017 kl. 18:49:50 UTC+1 skrev jonas.t...@gmail.com:
> > > > >> > I draw out graphic and sometime i want optional data upon the
> > > > lineart, but not always, redraw does call the animation every x
> > > > millisec, i really do not want multiple loops because that effect the
> > > > performance?
> > > > >> >
> > > > >> > So can you have if statement within a loop that is not checked
> > > > again and again but just once?
> > > > >> >
> > > > >> > Yeah i know it sounds ridiculous, it sounds like a different
> > > > programming paradigm.
> > > > >> >
> > > > >> > But people must be dealing with this kind of issues when writing
> > > > out big sets of data that sometimes they want the exra info/data and
> > > > somtimes omitted.
> > > > >>
> > > > >> Actually it would be 3 versions and so on for every optional data
> > > > you want, and their combinations, i think it is weird programming
> > > > languages do not have built in functionality to handle cases?
> > > > >>
> > > > >> Or is there a way to omit different set of information in
> > > > javascripts loops?
> > > > >
> > > > >Before hardware CGI and gpu era how did people handle select write
> > > > out wireframe and switch to polygon mesh? Maybe it was totally
> > > > different routines?
> > > > >
> > > > >But there must be cases even with large bulk transactions where
> > > > speed requirements, how to the handle optional data in loops? It seem
> > > > weird to check again and again once you concluded it should or should
> > > > not be written out.
> > > >
> > > > Speed is not usually as much of an issue as many people think.
> > > > Try benchmarking your code to see if it really needs the extra speed.
> > > >
> > > > Use an if. You could write two versions:
> > > >
> > > > if optionshouldberun()
> > > > for i=1 to numthings
> > > > requiredthing(i)
> > > > optionalthing(i)
> > > > else
> > > > for i=1 to numthings
> > > > requiredthing(i)
> > > >
> > > > This gets nasty when you have a bunch of this and have to modify
> > > > your code so use it judiciously.
> > > >
> > > > Sincerely,
> > > >
> > > > Gene Wirchenko
> > >
> > > I probably do things backward Gene, but right now my code poll a redraw every x millsec. This redraw function call paintOut. Now the cordinates used in paintOut is contantly changing.
> > >
> > > So with your approach i remove polling? the conditions "met" for every recurring paintout.
> > >
> > > But it still have to check for every redraw every x millisec.
> > >
> > > Unless i move up the if condition and have two or more redraw routines.
> > > Well it is so weird.
> > >
> > > Is there languages with cases only run once inside loop?
> > > like having a boolean handler to a codeblock if the conditions met the code will be run otherwise the codeblock omitted within loop?
> > >
> > > Something like this?
> > > boolCase1=true;
> > > boolCase2=false;
> > > boolCase3=true;
> > > while(x<10,boolCase1, boolCase2, boolCase3){
> > > boolCase1:
> > > boolCase2: //This codeblock will be omitted because not true
> > > boolCase3:
> > > }
> >
> > Well above seem a little redundant.
> >
> > boolCase1=true;
> > boolCase2=false;
> > boolCase3=true;
> > boolCase1:{code here}
> > boolCase2:{code here}
> > boolCase3:{code here}
> > while(x<10,boolCase1, boolCase2, boolCase3);
> >
> > or like this
> >
> > boolCase1=true;
> > boolCase2=false;
> > boolCase3=true;
> >
> > while(x<10){
> > boolCase1:{code here}
> > boolCase2:{code here}
> > boolCase3:{code here}
> > }
>
> But maybe this is considered to be ugly goto programming, but it seem rather straightforward, it really save some ugly fiddling?
Probably the upper code make more sense it suggest the check is before loop.
boolCase1=true;
boolCase2=false;
boolCase3=true;
boolCase1:{code here}
boolCase2:{code here}
boolCase3:{code here}
while(x<10,boolCase1, boolCase2, boolCase3);
While this suggest that the boolCases can be changed from inside the loop caseparts.
boolCase1=true;
boolCase2=false;
boolCase3=true;
while(x<10){
boolCase1:{code here}
boolCase2:{code here}
boolCase3:{code here}
}
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2017-02-10 20:49 -0800 |
| Message-ID | <e20ed1a6-304b-4c58-a69e-0deb2f47bab2@googlegroups.com> |
| In reply to | #32605 |
Den lördag 11 februari 2017 kl. 05:24:32 UTC+1 skrev jonas.t...@gmail.com:
> Den lördag 11 februari 2017 kl. 05:11:30 UTC+1 skrev jonas.t...@gmail.com:
> > Den lördag 11 februari 2017 kl. 04:57:05 UTC+1 skrev jonas.t...@gmail.com:
> > > Den lördag 11 februari 2017 kl. 04:46:20 UTC+1 skrev jonas.t...@gmail.com:
> > > > Den fredag 10 februari 2017 kl. 22:54:25 UTC+1 skrev Gene Wirchenko:
> > > > > On Fri, 10 Feb 2017 10:19:34 -0800 (PST), jonas.thornvall@gmail.com
> > > > > wrote:
> > > > >
> > > > > >Den fredag 10 februari 2017 kl. 18:55:51 UTC+1 skrev jonas.t...@gmail.com:
> > > > > >> Den fredag 10 februari 2017 kl. 18:49:50 UTC+1 skrev jonas.t...@gmail.com:
> > > > > >> > I draw out graphic and sometime i want optional data upon the
> > > > > lineart, but not always, redraw does call the animation every x
> > > > > millisec, i really do not want multiple loops because that effect the
> > > > > performance?
> > > > > >> >
> > > > > >> > So can you have if statement within a loop that is not checked
> > > > > again and again but just once?
> > > > > >> >
> > > > > >> > Yeah i know it sounds ridiculous, it sounds like a different
> > > > > programming paradigm.
> > > > > >> >
> > > > > >> > But people must be dealing with this kind of issues when writing
> > > > > out big sets of data that sometimes they want the exra info/data and
> > > > > somtimes omitted.
> > > > > >>
> > > > > >> Actually it would be 3 versions and so on for every optional data
> > > > > you want, and their combinations, i think it is weird programming
> > > > > languages do not have built in functionality to handle cases?
> > > > > >>
> > > > > >> Or is there a way to omit different set of information in
> > > > > javascripts loops?
> > > > > >
> > > > > >Before hardware CGI and gpu era how did people handle select write
> > > > > out wireframe and switch to polygon mesh? Maybe it was totally
> > > > > different routines?
> > > > > >
> > > > > >But there must be cases even with large bulk transactions where
> > > > > speed requirements, how to the handle optional data in loops? It seem
> > > > > weird to check again and again once you concluded it should or should
> > > > > not be written out.
> > > > >
> > > > > Speed is not usually as much of an issue as many people think.
> > > > > Try benchmarking your code to see if it really needs the extra speed.
> > > > >
> > > > > Use an if. You could write two versions:
> > > > >
> > > > > if optionshouldberun()
> > > > > for i=1 to numthings
> > > > > requiredthing(i)
> > > > > optionalthing(i)
> > > > > else
> > > > > for i=1 to numthings
> > > > > requiredthing(i)
> > > > >
> > > > > This gets nasty when you have a bunch of this and have to modify
> > > > > your code so use it judiciously.
> > > > >
> > > > > Sincerely,
> > > > >
> > > > > Gene Wirchenko
> > > >
> > > > I probably do things backward Gene, but right now my code poll a redraw every x millsec. This redraw function call paintOut. Now the cordinates used in paintOut is contantly changing.
> > > >
> > > > So with your approach i remove polling? the conditions "met" for every recurring paintout.
> > > >
> > > > But it still have to check for every redraw every x millisec.
> > > >
> > > > Unless i move up the if condition and have two or more redraw routines.
> > > > Well it is so weird.
> > > >
> > > > Is there languages with cases only run once inside loop?
> > > > like having a boolean handler to a codeblock if the conditions met the code will be run otherwise the codeblock omitted within loop?
> > > >
> > > > Something like this?
> > > > boolCase1=true;
> > > > boolCase2=false;
> > > > boolCase3=true;
> > > > while(x<10,boolCase1, boolCase2, boolCase3){
> > > > boolCase1:
> > > > boolCase2: //This codeblock will be omitted because not true
> > > > boolCase3:
> > > > }
> > >
> > > Well above seem a little redundant.
> > >
> > > boolCase1=true;
> > > boolCase2=false;
> > > boolCase3=true;
> > > boolCase1:{code here}
> > > boolCase2:{code here}
> > > boolCase3:{code here}
> > > while(x<10,boolCase1, boolCase2, boolCase3);
> > >
> > > or like this
> > >
> > > boolCase1=true;
> > > boolCase2=false;
> > > boolCase3=true;
> > >
> > > while(x<10){
> > > boolCase1:{code here}
> > > boolCase2:{code here}
> > > boolCase3:{code here}
> > > }
> >
> > But maybe this is considered to be ugly goto programming, but it seem rather straightforward, it really save some ugly fiddling?
>
> Probably the upper code make more sense it suggest the check is before loop.
> boolCase1=true;
> boolCase2=false;
> boolCase3=true;
> boolCase1:{code here}
> boolCase2:{code here}
> boolCase3:{code here}
> while(x<10,boolCase1, boolCase2, boolCase3);
>
> While this suggest that the boolCases can be changed from inside the loop caseparts.
>
> boolCase1=true;
> boolCase2=false;
> boolCase3=true;
>
> while(x<10){
> boolCase1:{code here}
> boolCase2:{code here}
> boolCase3:{code here}
> }
https://en.wikipedia.org/wiki/Duff%27s_device
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2017-02-10 21:38 -0800 |
| Message-ID | <930ecc2a-1d53-4eb7-92c4-602d5a7ce965@googlegroups.com> |
| In reply to | #32606 |
Den lördag 11 februari 2017 kl. 05:49:37 UTC+1 skrev jonas.t...@gmail.com:
> Den lördag 11 februari 2017 kl. 05:24:32 UTC+1 skrev jonas.t...@gmail.com:
> > Den lördag 11 februari 2017 kl. 05:11:30 UTC+1 skrev jonas.t...@gmail.com:
> > > Den lördag 11 februari 2017 kl. 04:57:05 UTC+1 skrev jonas.t...@gmail.com:
> > > > Den lördag 11 februari 2017 kl. 04:46:20 UTC+1 skrev jonas.t...@gmail.com:
> > > > > Den fredag 10 februari 2017 kl. 22:54:25 UTC+1 skrev Gene Wirchenko:
> > > > > > On Fri, 10 Feb 2017 10:19:34 -0800 (PST), jonas.thornvall@gmail.com
> > > > > > wrote:
> > > > > >
> > > > > > >Den fredag 10 februari 2017 kl. 18:55:51 UTC+1 skrev jonas.t...@gmail.com:
> > > > > > >> Den fredag 10 februari 2017 kl. 18:49:50 UTC+1 skrev jonas.t...@gmail.com:
> > > > > > >> > I draw out graphic and sometime i want optional data upon the
> > > > > > lineart, but not always, redraw does call the animation every x
> > > > > > millisec, i really do not want multiple loops because that effect the
> > > > > > performance?
> > > > > > >> >
> > > > > > >> > So can you have if statement within a loop that is not checked
> > > > > > again and again but just once?
> > > > > > >> >
> > > > > > >> > Yeah i know it sounds ridiculous, it sounds like a different
> > > > > > programming paradigm.
> > > > > > >> >
> > > > > > >> > But people must be dealing with this kind of issues when writing
> > > > > > out big sets of data that sometimes they want the exra info/data and
> > > > > > somtimes omitted.
> > > > > > >>
> > > > > > >> Actually it would be 3 versions and so on for every optional data
> > > > > > you want, and their combinations, i think it is weird programming
> > > > > > languages do not have built in functionality to handle cases?
> > > > > > >>
> > > > > > >> Or is there a way to omit different set of information in
> > > > > > javascripts loops?
> > > > > > >
> > > > > > >Before hardware CGI and gpu era how did people handle select write
> > > > > > out wireframe and switch to polygon mesh? Maybe it was totally
> > > > > > different routines?
> > > > > > >
> > > > > > >But there must be cases even with large bulk transactions where
> > > > > > speed requirements, how to the handle optional data in loops? It seem
> > > > > > weird to check again and again once you concluded it should or should
> > > > > > not be written out.
> > > > > >
> > > > > > Speed is not usually as much of an issue as many people think.
> > > > > > Try benchmarking your code to see if it really needs the extra speed.
> > > > > >
> > > > > > Use an if. You could write two versions:
> > > > > >
> > > > > > if optionshouldberun()
> > > > > > for i=1 to numthings
> > > > > > requiredthing(i)
> > > > > > optionalthing(i)
> > > > > > else
> > > > > > for i=1 to numthings
> > > > > > requiredthing(i)
> > > > > >
> > > > > > This gets nasty when you have a bunch of this and have to modify
> > > > > > your code so use it judiciously.
> > > > > >
> > > > > > Sincerely,
> > > > > >
> > > > > > Gene Wirchenko
> > > > >
> > > > > I probably do things backward Gene, but right now my code poll a redraw every x millsec. This redraw function call paintOut. Now the cordinates used in paintOut is contantly changing.
> > > > >
> > > > > So with your approach i remove polling? the conditions "met" for every recurring paintout.
> > > > >
> > > > > But it still have to check for every redraw every x millisec.
> > > > >
> > > > > Unless i move up the if condition and have two or more redraw routines.
> > > > > Well it is so weird.
> > > > >
> > > > > Is there languages with cases only run once inside loop?
> > > > > like having a boolean handler to a codeblock if the conditions met the code will be run otherwise the codeblock omitted within loop?
> > > > >
> > > > > Something like this?
> > > > > boolCase1=true;
> > > > > boolCase2=false;
> > > > > boolCase3=true;
> > > > > while(x<10,boolCase1, boolCase2, boolCase3){
> > > > > boolCase1:
> > > > > boolCase2: //This codeblock will be omitted because not true
> > > > > boolCase3:
> > > > > }
> > > >
> > > > Well above seem a little redundant.
> > > >
> > > > boolCase1=true;
> > > > boolCase2=false;
> > > > boolCase3=true;
> > > > boolCase1:{code here}
> > > > boolCase2:{code here}
> > > > boolCase3:{code here}
> > > > while(x<10,boolCase1, boolCase2, boolCase3);
> > > >
> > > > or like this
> > > >
> > > > boolCase1=true;
> > > > boolCase2=false;
> > > > boolCase3=true;
> > > >
> > > > while(x<10){
> > > > boolCase1:{code here}
> > > > boolCase2:{code here}
> > > > boolCase3:{code here}
> > > > }
> > >
> > > But maybe this is considered to be ugly goto programming, but it seem rather straightforward, it really save some ugly fiddling?
> >
> > Probably the upper code make more sense it suggest the check is before loop.
> > boolCase1=true;
> > boolCase2=false;
> > boolCase3=true;
> > boolCase1:{code here}
> > boolCase2:{code here}
> > boolCase3:{code here}
> > while(x<10,boolCase1, boolCase2, boolCase3);
> >
> > While this suggest that the boolCases can be changed from inside the loop caseparts.
> >
> > boolCase1=true;
> > boolCase2=false;
> > boolCase3=true;
> >
> > while(x<10){
> > boolCase1:{code here}
> > boolCase2:{code here}
> > boolCase3:{code here}
> > }
> https://en.wikipedia.org/wiki/Duff%27s_device
Performance[edit]
Many compilers will optimize the switch into a jump table just as would be done in an assembly implementation.
The primary increase in speed versus a simple, straightforward loop, comes from loop unwinding that reduces the number of performed branches, which are computationally expensive due to the need to flush—and hence stall—the instruction pipeline. The switch statement is used to handle the remainder of the data not evenly divisible by the number of operations unrolled (in this example, eight byte moves are unrolled, so the switch handles an extra 1–7 bytes automatically).
Does Duff's ideas apply to the above, i can see that javascript isn't exactly lowlevel, but surely it could benefit using a structure that let looped codeblocks be optional during the interpretation or is it "runtime compilation?".
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web