Confusion

 BBS: Inland Empire Archive
Date: 04-13-92 (17:47)             Number: 152
From: DON KROUSE                   Refer#: NONE
  To: ALL                           Recvd: NO  
Subj: Confusion                      Conf: (2) Quik_Bas
I had always heard that QuickBasic's LOCATE and PRINT routines were
very slow and that you should use ASM routines instead. I recently
posted a message showing that PEEK/POKE didn't seem to be too much
slower than an assembly routine. After posting that message I got
curious about how much slower using:
        LOCATE X, Y
        COLOR 7, 1
        PRINT; Msg$
would be. I included LOCATE and COLOR because both the PEEK/POKE
and the ASM routines support it. I was supprised by the results!
It appears that for string lengths up to 3 or 4 characters long the
PEEK/POKE method is faster, from about 4 to 15 characters ASM is
faster and for string lengths longer than about 15 characters the
LOCATE/COLOR/PRINT method becomes significantly faster.

Notice that the PRINT method seems to have plateaus where the speed
remains consistent over a range of string lengths.
e.g. 30 to 34, 35 to 44, 45 to 62 and 63 to 80

Can someone explain what is going on? Why is PRINT faster?

The test shows the time in seconds that it took to do 5,000 loops
of each type of screen printing routine for strings from  1 to 80
characters in length. The last two columns show the speed of the
LOCATE/PRINT/COLOR routine relative to the assembly routine and the
PEEK/POKE routine relative to the assembly routine.

P L E A S E   S E E   T H E   N E X T   M E S S A G E   A L S O

String   --------- R O U T I N E ---------
Length   LOCATE/PRINT  PEEK/POKE     ASM     PRT/ASM POKE/ASM
       1      2.58203    0.71094    0.82031   314.76%   86.67%
       2      2.96094    1.15234    1.21094   244.52%   95.16%
       3      3.30078    1.64063    1.65234   199.76%   99.29%
       4      3.61719    2.14063    2.08984   173.08%  102.43%
       5      3.94922    2.51953    2.47266   159.72%  101.90%
       6      4.17969    3.01953    2.91016   143.62%  103.76%
       7      4.61328    3.47266    3.30078   139.76%  105.21%
       8      4.89063    3.89844    3.74219   130.69%  104.18%
       9      5.16016    4.33984    4.16797   123.81%  104.12%
      10      5.55078    4.83984    4.56250   121.66%  106.08%
      11      5.54688    5.28125    5.00000   110.94%  105.62%
      12      5.92969    5.71094    5.38672   110.08%  106.02%
      13      6.37109    6.21094    5.82031   109.46%  106.71%
      14      6.37109    6.60156    6.19922   102.77%  106.49%
      15      6.92188    7.08984    6.65234   104.05%  106.58%
      16      6.92188    7.57813    7.07813    97.79%  107.06%
      17      7.58203    7.96875    7.46875   101.52%  106.69%
      18      7.57813    8.46094    7.91016    95.80%  106.96%
      19      7.58203    8.90234    8.29688    91.38%  107.30%
      20      8.30078    9.39063    8.73828    94.99%  107.47%
      21      8.28906    9.78125    9.17188    90.37%  106.64%
      22      8.35156   10.26953    9.55078    87.44%  107.53%
      23      9.23047   10.71094    9.99219    92.38%  107.19%
      24      9.23047   11.15234   10.37891    88.93%  107.45%
      25      9.28125   11.64063   10.82031    85.78%  107.58%
      26     10.38672   12.07813   11.25781    92.26%  107.29%
      27     10.37891   12.52734   11.64844    89.10%  107.55%
      28     10.37891   13.01953   12.08984    85.85%  107.69%
      29     10.60156   13.44922   12.46875    85.03%  107.86%
      30     11.91797   13.89844   12.89844    92.40%  107.75%
      31     11.91797   14.39063   13.35156    89.26%  107.78%
      32     11.91797   14.78125   13.72656    86.82%  107.68%
      33     11.91797   15.26953   14.17969    84.05%  107.69%
      34     11.92188   15.71094   14.55078    81.93%  107.97%
      35     13.89063   16.14844   15.00000    92.60%  107.66%
      36     13.89844   16.58984   15.42969    90.08%  107.52%
      37     13.90234   17.08203   15.82031    87.88%  107.98%
      38     13.89844   17.51953   16.26172    85.47%  107.73%
      39     13.89063   17.96094   16.63672    83.49%  107.96%
      40     13.89844   18.45703   17.08203    81.36%  108.05%
      41     13.89844   18.89844   17.51953    79.33%  107.87%
      42     13.89844   19.33984   17.91016    77.60%  107.98%
      43     13.90234   19.82813   18.33984    75.80%  108.12%
      44     13.90234   20.20703   18.73047    74.22%  107.88%
      45     16.63672   20.70703   19.17188    86.78%  108.01%
      46     16.65234   21.19922   19.60938    84.92%  108.11%
      47     16.64063   21.58984   20.00000    83.20%  107.95%
      48     16.64063   22.08203   20.42969    81.45%  108.09%
      49     16.64063   22.51953   20.81250    79.95%  108.20%
      50     16.64063   22.96094   21.25000    78.31%  108.05%
      51     16.64844   23.39063   21.69922    76.72%  107.79%
      52     16.64063   23.89063   22.08203    75.36%  108.19%
      53     16.65234   24.32813   22.51953    73.95%  108.03%
      54     16.64063   24.76953   22.89844    72.67%  108.17%
      55     16.64063   25.26953   23.33984    71.30%  108.27%
      56     16.64844   25.64844   23.78125    70.01%  107.85%
      57     16.63672   26.13672   24.16797    68.84%  108.15%
      58     16.64063   26.58984   24.60156    67.64%  108.08%
      59     16.63672   27.07813   24.99219    66.57%  108.35%
      60     16.65234   27.51172   25.42969    65.48%  108.19%
      61     16.64063   27.96094   25.86719    64.33%  108.09%
      62     16.75000   28.39844   26.25000    63.81%  108.18%
continued in next message
---
 * Origin: Silver Lake Systems * Bothell, WA (1:343/58)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET