Jump to content
OLD CS1

BASIC and Extended BASIC subprogram and function execution times

Recommended Posts

Is there a list of execution times for subprogram, functions, statements, and operations in TI BASIC or TI Extended BASIC?  ISTR someone way back posting about how long it takes to execute certain mathematical routines, I think during a glancing discussion on the speed of DEF.

  • Like 3

Share this post


Link to post
Share on other sites

I think the execution times depend on the statement, function, subprogram, etc. If you want to know how long something takes, you can set up a loop like this:

10 X=X+1

20 GOTO 10

Run this for a minute, print X and you can find out how long each iteration of an empty loop takes.

Then add what you want to test:

15 S=SIN(.5)

Run that for a minute, print X and you can find out how long each loop takes. Subtract the amount of time for each iteration of an empty loop and you know how long it takes to perform S=SIN(.5)

  • Like 2

Share this post


Link to post
Share on other sites

And then, after a taking a little mental health time for yourself, to recover from the shock, you ask senior_falcon how to use his compiler.  :) 

  • Like 1
  • Haha 1

Share this post


Link to post
Share on other sites

The compiler is a game changer!  Pun intended.

Collision detection works! The single most disappointing part of XB as a 12 year old!  LOL

 

Beyond the speed increases across XB are the new commands he has already added and working on adding The Missing Link stuff also!  

Different Graphic modes etc.

 

ALL Great stuff!  

 

  • Like 3

Share this post


Link to post
Share on other sites
13 minutes ago, 1980gamer said:

The compiler is a game changer!  Pun intended.

Collision detection works! The single most disappointing part of XB as a 12 year old!  LOL

 

Beyond the speed increases across XB are the new commands he has already added and working on adding The Missing Link stuff also!  

Different Graphic modes etc.

 

ALL Great stuff!  

 

Yes, the compiler is all that and a bag of chips, I have used it before, but the compiler is beyond the scope of the question.

Share this post


Link to post
Share on other sites
4 hours ago, senior_falcon said:

I think the execution times depend on the statement, function, subprogram, etc. If you want to know how long something takes, you can set up a loop like this:

10 X=X+1

20 GOTO 10

Run this for a minute, print X and you can find out how long each iteration of an empty loop takes.

Then add what you want to test:

15 S=SIN(.5)

Run that for a minute, print X and you can find out how long each loop takes. Subtract the amount of time for each iteration of an empty loop and you know how long it takes to perform S=SIN(.5)

I always used FOR X=1 TO 1000.

Since it's 1000 loops, you can measure the time, and the number of seconds you get is the number of milliseconds per loop. Run the bare loop first, of course, to measure the FOR..NEXT time.

Of course, in TI BASIC some commands will run you out of patience before they complete - CALL GCHAR is the worst. You can use a shorter loop and multiply the result to get a reasonable estimate. (Say, 1 TO 200, and multiply by 5).

 

Share this post


Link to post
Share on other sites
1 hour ago, OLD CS1 said:

Yes, the compiler is all that and a bag of chips, I have used it before, but the compiler is beyond the scope of the question.

Understood...  Was just Agreeing with TheBF.

51 minutes ago, Tursi said:

I always used FOR X=1 TO 1000.

Since it's 1000 loops, you can measure the time, and the number of seconds you get is the number of milliseconds per loop. Run the bare loop first, of course, to measure the FOR..NEXT time.

Of course, in TI BASIC some commands will run you out of patience before they complete - CALL GCHAR is the worst. You can use a shorter loop and multiply the result to get a reasonable estimate. (Say, 1 TO 200, and multiply by 5).

 

Yes, if we could replace GCHAR with faster linked version... I use this command all the time.  I like thing dynamic and random.

I could replace it in a lot of cases with coordinate lists, but then I need to know everything in advance.

Example:  I did a pacman demo. I could drop a new maze in of any config.  As long as side doors did not move or I could put a variable for each maze for door locations. 

Because GCHAR lets me look for walls.   If I did a list, I would have to do a list for each maze and I am very lazy!

  • Like 1

Share this post


Link to post
Share on other sites
Posted (edited)
2 hours ago, Tursi said:

I always used FOR X=1 TO 1000.

Since it's 1000 loops, you can measure the time, and the number of seconds you get is the number of milliseconds per loop. Run the bare loop first, of course, to measure the FOR..NEXT time.

Of course, in TI BASIC some commands will run you out of patience before they complete - CALL GCHAR is the worst. You can use a shorter loop and multiply the result to get a reasonable estimate. (Say, 1 TO 200, and multiply by 5).

 

Yep, that way is good too and in some ways simpler. I like doing it for one minute because, with my short attention span, I don't have hover over the stop watch trying to be ready for when the program ends. When the minute is up you press "break". But of course then you then have to divide 60 by X to get the milliseconds.

Six of one and twelve dozen of the other, as my buddy Don used to say.

 

(Edit) In TI BASIC GCHAR and HCHAR take about the same amount of time.

Edited by senior_falcon
  • Like 1

Share this post


Link to post
Share on other sites
2 hours ago, Tursi said:

Of course, in TI BASIC some commands will run you out of patience before they complete - CALL GCHAR is the worst. You can use a shorter loop and multiply the result to get a reasonable estimate. (Say, 1 TO 200, and multiply by 5).

I took a another whack at my general input routine.

 

https://atariage.com/forums/blogs/entry/17054-ti-basic-search-for-a-fast-and-easy-input-routine-for-games/

 

The replacement formula in the comment is 2.4 seconds faster per 100 iterations.  Rather considerable.  This got me thinking that a table of execution speeds of TI BASIC elements, including variations of retrieving literals or variables, would be useful to some.

 

Share this post


Link to post
Share on other sites
8 hours ago, senior_falcon said:

(Edit) In TI BASIC GCHAR and HCHAR take about the same amount of time.

Interesting... confirmed.

 

I remember back in the day that a discussion of execution time, and a list of the statements, was in one of the old magazines (which means it must have been in 99er or HCM, cause I didn't have access to Micropendium?) And I was sure that I tested GCHAR against HCHAR specifically.

 

Just goes to show we all carry some misconceptions we learned and it's always worth re-testing if you didn't write it down the first time. ;)

 

Anyway... if anyone has a way to text search, you might be able to find the original article?

 

Share this post


Link to post
Share on other sites
9 hours ago, senior_falcon said:

(Edit) In TI BASIC GCHAR and HCHAR take about the same amount of time.

This may imply that working with variables or literals may carry similar time costs.

Share this post


Link to post
Share on other sites

I think another thing with GCHAR is you have to do something with the returned value.

 

an IF or an ON etc. 

 

HCHAR is what it is!  Well, you could also repeat and slow that command a lot!

 

Share this post


Link to post
Share on other sites
2 hours ago, 1980gamer said:

HCHAR is what it is!  Well, you could also repeat and slow that command a lot!

 

Yeah—but VCHAR should be phenomenally worse on repeats because the VDP Write Address must be set for each and every byte written to VRAM, whereas HCHAR only needs to do it once.

 

...lee

  • Like 3

Share this post


Link to post
Share on other sites
47 minutes ago, Lee Stewart said:

 

Yeah—but VCHAR should be phenomenally worse on repeats because the VDP Write Address must be set for each and every byte written to VRAM, whereas HCHAR only needs to do it once.

 

...lee

Both are pretty poor although VCHAR is a little worse. In the program below, for HCHAR there are 69 loops in 1 minute, for VCHAR there are 47


10 X=X+1
20 CALL VCHAR(1,1,42,768)
30 GOTO 10

Share this post


Link to post
Share on other sites
1 hour ago, senior_falcon said:

Both are pretty poor although VCHAR is a little worse. In the program below, for HCHAR there are 69 loops in 1 minute, for VCHAR there are 47


10 X=X+1
20 CALL VCHAR(1,1,42,768)
30 GOTO 10

I have always wondered how HCHAR was implemented. I can't think of a reason for it to be that slow unless they wanted the timing to look like VCHAR. (?)

Share this post


Link to post
Share on other sites

It's written in GPL. Looks like FMT is used to display the characters. (Rich can explain about FMT - I know nothing about it) An XML routine would have perked this up quite a bit.

  • Like 2

Share this post


Link to post
Share on other sites
12 hours ago, TheBF said:

I have always wondered how HCHAR was implemented. I can't think of a reason for it to be that slow unless they wanted the timing to look like VCHAR. (?)

Spoiler

<0090>               ***********************************************************
<0091>               * SUBROUTINE TO GET ROW, COLUMN VALUES                     
<0092>               ***********************************************************
<0093>               * RXB PATCH CODE
<0094> ACA9 06,AC,89 GPHV   CALL LPAR              Insure '(', parse, insure ','
<0095>               * RXB PATCH CODE
<0096> ACAC 0F,7E    GPHVRC XML  SPEED             Insure in range
<0097> ACAE 02              BYTE RANGE           *  of 1 - 24
<0098> ACAF 01              BYTE 1
<0099> ACB0 00,18           DATA 24
<0100> ACB2 92,4B           DEC  @FAC1             Adjust to internal range
<0101> ACB4 BC,02,7F        ST   @XPT,@MNUM
<0102> ACB7 BC,7E,4B        ST   @FAC1,@YPT        Set row pointer
<0103> ACBA 0F,7E           XML  SPEED             Get column value
<0104> ACBC 01              BYTE PARCOM          *  and insure a comma
<0105> ACBD 0F,7E           XML  SPEED             Insure in range
<0106> ACBF 02              BYTE RANGE           *  of 1 to 32
<0107> ACC0 01              BYTE 1
<0108> ACC1 00,20           DATA 32
<0109> ACC3 92,4B           DEC  @FAC1             Internal range: 0 - 31
<0110> ACC5 BC,7F,4B        ST   @FAC1,@XPT        Set column pointer
<0111> ACC8 00              RTN

<0119>               * Get ROW, COLUMN VALUES AND NUMBER OF CHARACTERS
<0120> ACD6 06,AC,A9 HVCHR  CALL GPHV              Get X, Y VALUES
<0121> ACD9 0F,74           XML  PARSE
<0122> ACDB B6              BYTE RPARZ
<0123> ACDC 06,A9,95        CALL INTARG
<0124> ACDF A2,4B,60        ADD  OFFSET,@FAC1
<0125> ACE2 BC,00,4B        ST   @FAC1,@VAR0       SAVE THE CHARACTER
<0126> ACE5 BF,4A,00        DST  1,@FAC            ASSUME 1 CHARACTER
       ACE8 01
<0127> ACE9 D6,42,B6        CEQ  RPARZ,@CHAT       If not right parenthesis
<0128> ACEC 6C,F8           BS   GAC95
<0129> ACEE 0F,7E           XML  SPEED             Must be
<0130> ACF0 00              BYTE SYNCHK          *   at a
<0131> ACF1 B3              BYTE COMMAZ          *    comma
<0132> ACF2 0F,74           XML  PARSE             # OF CHARACTERS
<0133> ACF4 B6              BYTE RPARZ
<0134> ACF5 06,A9,95        CALL INTARG            FLOATING TO INTEGER
<0135> ACF8 00       GAC95  RTN
<0136>               ***********************************************************

<0252>               ***********************************************************
<0253>               *                SUBPROGRAM FOR 'HCHAR'                    
<0254>               ***********************************************************
<0255> AB03 06,AC,D6 HCHAR  CALL HVCHR             Get X, Y values character, # 
<0256> AB06 8F,4A           DCZ  @FAC              If 0 characters
<0257> AB08 6B,12           BS   HCHAR2
<0258> AB0A 08,E0,00 HCHAR1 BYTE >08,>E0,>00,>FB  * FMT '@VAR0'   Display horizo
       AB0D FB
<0259> AB0E 93,4A           DDEC @FAC              Done yet?
<0260> AB10 4B,0A           BR   HCHAR1            No, finish it
<0261>               * RXB PATCH CODE
<0262> AB12 D6,42,B3 HCHAR2 CEQ  COMMAZ,@CHAT
<0263> AB15 6B,03           BS   HCHAR
<0264> AB17 BC,7F,02 XPTRTN ST   @MNUM,@XPT        Restore X-pointer

99/4 GPL-ASSEMBLER (Pass 3) correct                                   PAGE 0036 
EQUATES EXEC-359
<0265> AB1A 0F,7E    LNKRTN XML  SPEED             Must be at
<0266> AB1C 00              BYTE SYNCHK        *     a right
<0267> AB1D B6              BYTE RPARZ         *      parenthesis
<0268> AB1E 06,6A,78 LNKRT2 CALL CHKEND            Check end of statement
<0269> AB21 4D,BA           BR   ERRSYN            If not end-of-stmt , error
<0270> AB23 06,00,12        CALL RETURN            Return to caller
<0271>               ***********************************************************
<0272>               *                SUBPROGRAM FOR 'VCHAR'                    
<0273>               ***********************************************************
<0274> AB26 06,AC,D6 VCHAR  CALL HVCHR             Get X, Y values character, # 
<0275> AB29 8F,4A           DCZ  @FAC              If 0 characters
<0276> AB2B 6B,3F           BS   VCHAR2
<0277> AB2D 08,E0,00 VCHAR1 BYTE >08,>E0,>00,>9E,>FB * FMT '@VAR0',>31 Display v
       AB30 9E,FB
<0278> AB32 93,4A           DDEC @FAC              Done yet?
<0279> AB34 6B,3F           BS   VCHAR2            Yes, return
<0280> AB36 8E,7E           CZ   @YPT              If not at start of colunm
<0281> AB38 4B,2D           BR   VCHAR1
<0282> AB3A 90,7F           INC  @XPT              Move X-ptr to right one colun
<0283> AB3C 05,AB,2D        B    VCHAR1
<0284>               * RXB PATCH CODE
<0285> AB3F D6,42,B3 VCHAR2 CEQ  COMMAZ,@CHAT
<0286> AB42 6B,26           BS   VCHAR
<0287> AB44 4B,17           BR   XPTRTN
<0288>               ***********************************************************

Both HCHAR and VCHAR uses the same type of main core command is FMT @>8300 in other words put byte at >8300 to Row & Col loaded.

i.e 

HCHAR1 BYTE >08,>E0,>00,>FB  * FMT '@VAR0'   Display horizontal

or

VCHAR1 BYTE >08,>E0,>00,>9E,>FB * FMT '@VAR0',>31 Display vertical

 

This is RXB 2001 source code so there are a few modification from normal XB that only allows 1 HCHAR or VCHAR per program line.

i.e. RXB CALL HCHAR(row,column,character,repetition,row,column,character,repetion,row,column,character,repetition)

  • Like 3

Share this post


Link to post
Share on other sites
57 minutes ago, RXB said:

Both HCHAR and VCHAR uses the same type of main core command is FMT @>8300 in other words put byte at >8300 to Row & Col loaded.

 

So, basically, FMT puts one character at a time on the screen by setting the VRAM address for each byte before writing it to VRAM, the only difference between HCHAR and VCHAR being how the next position is calculated. Do I have that right?

 

...lee

  • Like 1

Share this post


Link to post
Share on other sites
13 hours ago, Lee Stewart said:

 

So, basically, FMT puts one character at a time on the screen by setting the VRAM address for each byte before writing it to VRAM, the only difference between HCHAR and VCHAR being how the next position is calculated. Do I have that right?

 

...lee

XPT is >837F and YPT is >837E i.e. ROW & Column these are the GPL row and col and not used for anything else.

GPL has >837D is the character to be read or displayed per YPT:XPT values i.e. row & col values.

 

This is why HCHAR and VCHAR are so slow.

RXB has CALL HPUT(row,col,string) or CALL VPUT that uses strings or numbers or characters.

RXB has CALL HGET(row,col,length,string) or CALL VGET that are fetching strings or number or characters.

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...