That isn't always the case, although I always advocate writing maintainable code over needlessly optimising.
An example would be our system for which does some fairly heavy lifting that can handle just over 10 requests a second. Within this year we must scale it to 55 and to 500 within 5 years. All on basically the same hardware. We are adding a caching system in between the source of the requests and the subroutines that generate the response. While this makes the code harder to grok, it is very much needed for us to be able to scale as required One of the reasons people in C,C++, .NET et al are hand optimising code less and less is that the compilers have had a ton of work done to them to optimise the code at compile time for you. That means you get the best of both worlds. Easy to read people-efficient code that is then compile to machine-efficient code. UniData lacks this work on the compiler. I spent 2 days looking at the byte code it generated and then spent a few days in my spare time writing a Proof-of-Concept pre-processor that gave roughly a 6% speed increase on our existing code base. With more time to implement a proper parser we could get > 10% quite easily. This is stuff that should be the bread 'n' butter of the compiler so we don't need to think about it. -----Original Message----- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Kate Stanton Sent: Tuesday, 8 February 2011 11:38 AM To: U2 Users List Subject: Re: [U2] Does UV have a "BLOCK" command We used to try to write machine-efficient code. Now machines are so fast, our emphasis is on people-efficient, ie easier to maintain. On 8 February 2011 12:58, Dan McGrath <dmc...@imb.com.au> wrote: > I had many months ago as part of a project I'm working on (performance > pre-processor for UniBasic). > > I've recreated a (no-scientific) test to get some rough numbers. > > X=0 > LOOPS = 999999 > STIME = SYSTEM(9) > FOR I = 1 TO LOOPS > X += 1 > NEXT I > CRT SYSTEM(9) - STIME > X=0 > STIME = SYSTEM(9) > FOR I = 1 TO LOOPS > GOSUB INC.X > NEXT I > CRT SYSTEM(9) - STIME > STOP > INC.X: > X += 1 > RETURN > > This results in: > 385 > 608 > > So when an loop + addition takes 0.38 micro seconds The gosub adds an > extra 0.22 micro seconds > > > But, that isn't the whole truth. If you have a look at the byte code > BASIC produces, you can clearly see that it adds 4 bytes for each line > to indicate the line number. When it performs jumps (such as gosubs) > it always jumps to the appropriate byte position that is left in the > byte code to indicate the line number of the label. > > So, this means the above measurements are measure the overhead of the > extra line identifies as well (which is fine in practice) > > The below code compensates for that: > > X=0 > LOOPS = 999999 > STIME = SYSTEM(9) > FOR I = 1 TO LOOPS > X += 1 > X += 1 > X += 1 > X += 1 > NEXT I > CRT SYSTEM(9) - STIME > X=0 > STIME = SYSTEM(9) > FOR I = 1 TO LOOPS > GOSUB INC.X > NEXT I > CRT SYSTEM(9) - STIME > STOP > INC.X: > X += 1;X += 1; X += 1;X += 1 > RETURN > > Now we are comparing a loop, 4 additions and 4 lines vs a loop, a > GOSUB/RETURN, 4 additions and 4 lines. > > The results: > 939 > 1048 > > Or, the GOSUB/RETURN takes .11 microseconds. > > It's quite clear from the above timings that the line count is a > bigger performance overhead then using GOSUB/RETURN > > > Sorry for the overkill :) > > > -----Original Message----- > From: u2-users-boun...@listserver.u2ug.org > [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of > DavidJMurray > (mvdbs.com) > Sent: Tuesday, 8 February 2011 10:08 AM > To: u2-users@listserver.u2ug.org > Subject: Re: [U2] Does UV have a "BLOCK" command > > > Has anyone measured the overheads of the various methods of subroutine > calls within UniBasic? > > Is it of significance? > > djm > > > Kate Stanton wrote: >> >> Why not use a subroutine? >> Personally, I like subroutines! >> >> > > > ----- > > Learn and Do > Excel and Share > > > http://mvdbs.com http://mvdbs.com > -- > View this message in context: > http://old.nabble.com/Does-UV-have-a-%22BLOCK%22-command-tp30867376p30 > 86 > 8821.html > Sent from the U2 - Users mailing list archive at Nabble.com. > > _______________________________________________ > U2-Users mailing list > U2-Users@listserver.u2ug.org > http://listserver.u2ug.org/mailman/listinfo/u2-users > > ______________________________________________________________________ > This email has been scanned by the MessageLabs Email Security System. > For more information please visit http://www.messagelabs.com/email > ______________________________________________________________________ > ###################################################################### > ##################### The information transmitted in this message and > attachments (if any) is intended only for the person or entity to > which it is addressed. The message may contain confidential and/or > privileged material. Any review, retransmission, dissemination or > other use of or taking of any action in reliance upon this information > by persons or entities other than the intended recipient is > prohibited. If you received this in error, please contact the sender and > delete the material from any computer. > > The intended recipient of this e-mail may only use, reproduce, > disclose or distribute the information contained in this e-mail and any > attached files with the permission of IMB. > ###################################################################### > ##################### _______________________________________________ > U2-Users mailing list > U2-Users@listserver.u2ug.org > http://listserver.u2ug.org/mailman/listinfo/u2-users > -- Kate Stanton Walstan Systems Ltd 4 Kelmarna Ave, Herne Bay, Auckland 1011, New Zealand Phone: + 64 9 360 5310 Mobile: + 64 21 400 486 Email: k...@walstan.com _______________________________________________ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ ########################################################################################### The information transmitted in this message and attachments (if any) is intended only for the person or entity to which it is addressed. The message may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer. The intended recipient of this e-mail may only use, reproduce, disclose or distribute the information contained in this e-mail and any attached files with the permission of IMB. ########################################################################################### _______________________________________________ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users