TIP: Click on subject to list as thread! ANSI
echo: power_bas
to: ALL
from: BOB ZALE
date: 1998-03-27 05:12:00
subject: Re: Subs vs gosub:which i

From: Bob Zale 
Subject: Re: Subs vs gosub:which is faster
 
Barry Erick wrote:
>
> The gosub is faster because:
>  1) No long call
>  2) No parameters pushed on the stack
>  3) No dummy parameters pushed on the stack  (PB's 16 parameters are
>      always pushed on the stack weather you use them all or not
>  4) No parameters popped of the stack when in the sub
>  5) no dummy parameters popped off the stack
>  6) no far return
 
Barry --
 
Actually, that isn't quite correct.  Parameters are only passed on the
stack when they are declared.  Otherwise, none.  However, there is still
extra overhead in a Sub/Function, like initialization of locals, etc.
Overall, Gosubs tend to be much faster in a "benchmark" situation, where
there is minimal code being processed.  In a real world environment, the
difference tends to close quite a bit.
 
Bob Zale
PowerBASIC Inc.
 
*** QwkNews (tm) v2.1
 * [TN71] Toast House Import
--- GEcho 1.20/Pro
---------------
* Origin: Toast House Remote (1:100/561)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.