Shop OBEX P1 Docs P2 Docs Learn Events
Programming Speed — Parallax Forums

Programming Speed

Hello All,
Trying to find the "execution" speed of the PBASIC (GET/PUT) commands. Reason: I had to re-write some code in a SLOT and switched from Variables that was being re-used in certain routines and started using the (GET/PUT) Commands and GOSUB routines. Worked great, even had space left over (100 bytes)....GREAT.
But now that LOOP seems to be going almost 3,4 or more times slower. NOTE: I'm judging this by the DATA being printed on the DEBUG Terminal. Before I would add a PAUSE command to view the DATA on the Terminal. But now the PAUSE commands had to be removed.
The HELP file with the Editor does not give me the (GET/PUT) command "execution" speed.
Over all program still flows smoothly, but its nothing like comparing two (2) Variables and seeing the results fly by on the Terminal Screen exstreamly fast.

Need: Location of Execution speed of PBASIC commands for current and future projects.

Thanks for any help

Comments

  • JonnyMacJonnyMac Posts: 8,912
    edited 2017-10-23 13:20
    Remember that PBASIC is compiled bytecodes that are run from EEPROM -- getting exact timing can be very tricky. That said, if you have a spare pin, you can use it with a 'scope to measure timing. It's tedious, but I've actually done it. Back in 1999 I created a little alarm product for a water-pumping company using the stock BS2. I spent a couple days with a 'scope timing all of the paths through the code so that I could pad the loop to 100ms (coarse, I know, but worked for this project) no matter what path the code took. To test a bit of code I would make my spare pin go high, run the code, then make my spare pin go low; then I measured the pulse created with the 'scope.

    This is where the Stamp's big brother, the Propeller, really shines. It has a free-running counter than can be used to time bits of code. I do this all the time. It looks like this:
      elapsed := -cnt
    
      ' put code to test here
    
      elapsed += cnt - 544
    
    The variable called elapsed now holds the number of system ticks (usually 1/80,000,000th of a second) that elapsed while the code ran. The -544 part is removing the overhead used to capture the counter.
Sign In or Register to comment.