timed speeds
Speed testing of VSTB
August 23, 2000
Steven R. Wheeler
Test methodology
Using the SPEED.TXT program, individual statements are timed. During the
timing, interrupts are turned on, so that timing information is available.
This is also the state in which most applications will normally be running.
Debug is disabled, so that the cost associated with line number tokens isn't
present.
The time that each statement takes is measured as follows:
1. A FOR ... NEXT loop from 1 to 1000 is executed, with the statement under
test as the only statement within the loop. Just before the FOR statement
is executed, the time information is zeroed. Immediately after the final
NEXT statement of the loop, the timing information is read. It is then
converted into an elapsed time in milliseconds.
2. The above is repeated for both the S1 and S2. Tests were performed with
revision 5 boards. These speeds will generally be significantly faster
than revision 4 and earlier on the S1, and faster than revision 3 and
earlier on the S2. Newer revisions should be comparable to these numbers.
3. Times are reported in milliseconds.
4. Unless otherwise specified, BIT variables are memory locations, not I/O
locations.
5. This data can be further reduced to provide information such as "it takes
x milliseconds to load a byte variable; y milliseconds to store an integer
variable" etc.
6. Note that results for floating-point operations are not guaranteed to show
the absolute best- and worst-case timings. The numbers shown are intended
to be representative of the range of execution times.
S1 Rev 5 S2 Rev 5
-------- --------
Overhead 1.213 0.275
GLOBAL VARIABLE OPERATIONS
--------------------------
I/O Bit = Constant 0.279 0.062
I/O Bit = I/O Bit 0.328 0.071
Bit Variable = Constant 0.279 0.061
Bit Variable = I/O Bit 0.319 0.071
Bit Variable = Bit Variable 0.309 0.068
Bit Variable = Byte Variable 0.362 0.078
Bit Variable = Int Variable 0.249 0.053
Byte Variable = Constant 0.333 0.075
Byte Variable = Bit Variable 0.365 0.080
Byte Variable = Byte Variable 0.415 0.090
Byte Variable = Int Variable 0.305 0.066
Int Variable = Constant 0.218 0.047
Int Variable = Bit Variable 0.253 0.056
Int Variable = Byte Variable 0.303 0.065
Int Variable = Int Variable 0.194 0.037
Int Variable = Float Variable n/a 0.092*
Float Variable = Constant n/a 0.093
Float Variable = Int Variable n/a 0.091**
Float Variable = Float Variable n/a 0.078
Note: The next two lines are not actual execution times of the conversions; they are the
times which must be added to the numbers which reference them.
* Convert Float to Int n/a ~0-0.126
** Convert Int to Float n/a ~0-0.074
LOCAL VARIABLE OPERATIONS
-------------------------
Global Byte = Local Byte 0.305 0.065
Local Byte = Global Byte 0.307 0.065
Global Int = Local Int 0.197 0.037
Local Int = Global Int 0.197 0.037
Global Float = Local Float n/a 0.081
Local Float = Global Float n/a 0.081
PROCEDURE CALLS
---------------
Call subroutine, no args 0.493 0.135
Call VITAL subroutine, no args 0.760 0.193
Call subroutine, one const arg 0.605 0.162
Call subroutine, two const args 0.737 0.193
Call subroutine, one intvar arg 0.587 0.157
Call subroutine, two intvar args 0.688 0.180
Call subroutine, one floatvar arg n/a 0.180
Call subroutine, two floatvar args n/a 0.225
Call subroutine, one local byte 0.742 0.193
Call subroutine, one local int 0.684 0.182
Call subroutine, two local ints 0.787 0.202
Call subroutine, one local float n/a 0.202
Call subroutine, two local floats n/a 0.237
Byte = Function() AS BYTE 0.813 0.210
Int = Function() AS INTEGER 0.705 0.182
Float = Function() AS FLOAT n/a 0.218
ARITHMETIC and LOGICAL
----------------------
Intvar = Intvar + Intvar 0.404 0.082
Intvar = Intvar - Intvar 0.413 0.083
Intvar = Intvar * Intvar 0.688-0.844 0.138-0.168
Intvar = Intvar / Int 0.784-0.898 0.157-0.178
Intvar = Intvar \ Intvar 0.769-0.899 0.152-0.178
Intvar = -Intvar 0.282 0.057
Intvar = ABS(intvar) 0.279-0.324 0.057-0.065
Intvar = MIN(intvar, intvar) 0.434-0.439 0.088
Intvar = MAX(intvar, intvar) 0.434-0.439 0.088
Intvar = Intvar OR Intvar 0.393 0.081
Intvar = Intvar AND Intvar 0.393 0.081
Intvar = Intvar XOR Intvar 0.393 0.081
Intvar = NOT(Intvar) 0.279 0.057
Floatvar = Floatvar + Floatvar n/a 0.187-0.240
Floatvar = Floatvar - Floatvar n/a 0.187-0.245
Floatvar = Floatvar * Floatvar n/a 0.310-0.393
Floatvar = Floatvar / Floatvar n/a 0.526-0.632
Floatvar = -Floatvar n/a 0.106
Floatvar = ABS(Floatvar) n/a 0.106
Floatvar = MIN(Floatvar) n/a 0.178-0.187
Floatvar = MAX(Floatvar) n/a 0.178-0.187
Floatvar = SIN(Floatvar) n/a 1.018-2.423
Floatvar = COS(Floatvar) n/a 0.387-2.235
Floatvar = ARCTAN(Floatvar) n/a 0.518-3.330
Floatvar = LOG(Floatvar) n/a 0.736-3.651
All power operations raise 2 to the listed power. All values are in global variables.
Intvar = Intvar ^ negative 0.413 0.083
Intvar = Intvar ^ 0 0.407 0.083
Intvar = Intvar ^ 1 0.769 0.152
Intvar = Intvar ^ 2 1.132 0.225
Intvar = Intvar ^ 14 5.447 1.063
Floatvar = Floatvar ^ Floatvar n/a 0.172-6.885
CONTROL FLOW
------------
IF 1 | REM | ENDIF 0.249 0.057
IF 1 | REM | ELSE | REM | ENDIF 0.444 0.120
IF 0 | REM | ENDIF 0.344 0.093
IF 0 | REM | ELSE | REM | ENDIF 0.344 0.093
IF int < int | REM | ENDIF 0.472-0.567 0.100-0.135
IF int <= int | REM | ENDIF 0.474-0.600 0.100-0.141
IF int > int | REM | ENDIF 0.587-0.693 0.122-0.160
IF int >= int | REM | ENDIF 0.550-0.653 0.115-0.152
IF int = int | REM | ENDIF 0.459-0.553 0.097-0.132
IF int <> int | REM | ENDIF 0.537-0.642 0.112-0.150
IF float < float | REM | ENDIF n/a 0.160-0.198
IF float <= float | REM | ENDIF n/a 0.160-0.197
IF float > float | REM | ENDIF n/a 0.175-0.216
IF float >= float | REM | ENDIF n/a 0.173-0.210
IF float = float | REM | ENDIF n/a 0.162-0.193
IF float <> float | REM | ENDIF n/a 0.175-0.216
DO WHILE 0 | REM | LOOP 0.344 0.093
DO WHILE 1 | EXIT | LOOP 0.444 0.120
DO | REM | LOOP UNTIL 1 0.249 0.057
DO | EXIT | LOOP UNTIL 0 0.197 0.062
FOR int = 1 TO 10 | REM | NEXT 13.104 2.981
FOR int = 1 TO 20 | REM | NEXT 25.237 5.733
SPECIAL STATEMENTS
------------------
SET TIMERx TO 10 0.319 0.068
SET INT0 TO 1 0.527 0.112
RESTORE 0.259 0.057
READ intvar 1.020 0.240
READ floatvar n/a 0.291
PIPE PRINT LCD 0.279 0.061
PIPE PRINT COMM0 n/a 0.121
PIPE PRINT COMM1 0.549 0.121
For the following 4 measurements, PRINT output was PIPE'd to LCD
PRINT "*" (1 char) 0.960 0.297
PRINT "**********" (10 chars) 4.035 1.223
PRINT intvar 1.390-2.838 0.338- 0.766
PRINT fpvar n/a 1.346-15.373
For the following 4 measurements, PRINT output was PIPE'd to COMM0
PRINT "*" (1 char) n/a 0.773 (0.225)
PRINT "**********" (10 chars) n/a 10.145
PRINT intvar n/a 1.805- 5.970
PRINT fpvar n/a 12.217-24.506
For the following 4 measurements, PRINT output was PIPE'd to COMM1
PRINT "*" (1 char) 0.819 0.878 (0.225)
PRINT "**********" (10 chars) 11.365 11.177
PRINT intvar 1.558-6.249 2.013- 6.595
PRINT fpvar n/a 13.467-26.692
ARRAY ACCESS
------------
bytevar = barray[intvar] 0.834 0.210
barray[intvar] = bytevar 0.846-4.120 0.213- 3.363
intvar = iarray[intvar] 0.954 0.230
iarray[intvar] = intvar 1.057-7.632 0.545- 6.576
floatvar = farray[intvar] n/a 0.315
farray[intvar] = floatvar n/a 0.430-13.034
bytevar = barray[intvar,intvar] 1.568 0.360
barray[intvar,intvar] = bytevar 1.584-4.875 0.363- 3.514
intvar = iarray[intvar,intvar] 1.693 0.381
iarray[intvar,intvar] = intvar 1.795-8.358 0.423- 6.724
floatvar=farray[intvar,intvar] n/a 0.466
farray[intvar,intvar]=floatvar n/a 0.578-13.179
BUILT-IN PROCEDURES
-------------------
LCD_Command(0x01) 4.234 1.592
LCD_Command(0x80) 0.500 0.141
LCD_Display("**********") 4.035 1.225
bytevar = PEEK(const) 0.415 0.090
POKE(const, bytevar) 0.415 0.090
intvar = DPEEK(const) 0.309 0.065
DPOKE(const, intvar) 0.309 0.066
bytevar = EEPROM_PEEK(intvar) 0.599 0.162
EEPROM_POKE(intvar, bytevar) 0.611-3.889 0.162-3.315
intvar = info(array) 0.218 0.047
(SIZE_OF, ADDR_OF, ROWS_OF, COLS_OF)
PULSE_xx(6, 7, 0) 0.540 0.118
PULSE_xx(6, 7, 100) 2.215 0.445
PULSE_xx(6, 7, 1000) 17.274 3.388
TX(6, 7, 1, 8, 0, intvar) 1.397 0.302
TX(6, 7, 100, 8, 0, intvar) 15.802 3.107
TX(6, 7, 1000, 8, 0, intvar) 146.732 28.613
TX(6, 7, 1, 16, 0, intvar) 1.779 0.381
TX(6, 7, 100, 16, 0, intvar) 27.707 5.433
TX(6, 7, 1000, 16, 0, intvar) 263.384 51.342
intvar = KEYPAD(0) 0.839-0.978 0.150-0.177
intvar = KEYPAD(1) 0.769 0.136
intvar = KEY_PENDING() 0.203 0.037
intvar = COMM(0, 2, 0) n/a 0.132
intvar = COMM(1, 2, 0) 0.609 0.132
intvar = COMM(0, 1, 'a') n/a 0.773 (0.160)
intvar = COMM(1, 1, 'a') 0.777 0.878 (0.160)
VAST_CLOCK(const) n/a 0.110
VAST_OPEN(const) n/a 0.050
intvar=VAST_SPI_XFER(16,intvar) n/a 0.330
intvar=VAST_SPI_XFER(8,intvar) n/a 0.218
VAST_CLOSE(const) n/a 0.050
VAST_IIC_START() n/a 0.027
bytevar = VAST_IIC_READ(const) n/a 0.193
bitvar = VAST_IIC_SEND(bytevar) n/a 0.225
VAST_IIC_STOP() n/a 0.032
intvar = AIN(intvar) 0.387 0.101
INTERRUPT LATENCY
-----------------
Interrupt latency was measured using an oscilloscope and the following handler routine:
VITAL SUBROUTINE Handler(info AS INTEGER)
Keypad8 = Keypad7
SET INT0 TO 1
END
When this was enabled, and a square wave fed into the Keypad7 line, the following minimum times
were noted for the delay between the transitions on the two lines:
Response latency 1.000 0.250
Since the measured time includes the time necessary to execute an "IOBit = IOBit" instruction,
the actual latency to enter the subroutine is:
Actual latency 0.672 0.179
Note that this number represents the minimum time to respond to the interrupt, and may be longer
depending upon the particular instruction which is executing at the time the interrupt is received.
OTHER INFORMATION
-----------------
1. The fastest integer multiply noted was 1 x 1. The slowest noted was 1 x -32767.
2. The fastest integer divide noted was -32767 / -32767. The slowest noted was 32767 / -1.
3. The fastest integer modulus noted was 1 \ 32767. The slowest noted was -32767 \ 1.
4. No timings were performed on the ON and ON statements.
These statements will take a little longer than an integer write to EEPROM.
5. The fastest integer-to-float conversion is 0. The slowest is -1.
6. The fastest float-to-integer conversion is 0. The slowest is -1.
7. The fastest FP MIN() occurs when the numbers are different by at least a power of
two, and the first number is larger. The fastest FP MAX() occurs when the second
is larger. When the mantissas differ only in the LSBs, the operation goes slower.
8. The fastest FP addition occurs when the both numbers are the same, and the signs
are opposite (i.e., the result is zero). The slowest addition occurs when one
number is about 2^31 times the other. FP subtraction is similar.
9. The fastest FP multiply occurs when the both numbers have few '1' bits in the
mantissa. The more '1' bits, the slower the operation.
10. The fastest FP divide is a division by 1. The slowest is with a large number of
'1' bits in the mantissas of the two numbers.
11. The fastest SIN() noted was SIN(0). The slowest noted was SIN(0.001).
12. The fastest COS() noted was COS(0). The slowest noted was COS(pi/2).
13. The fastest ARCTAN() noted was ARCTAN(0). The slowest noted was ARCTAN(1000).
14. The fastest LOG() noted was LOG(1.0). The slowest noted was LOG(1000000).
15. The fastest FP x^y operation was 0^1. The slowest noted was 0.9999^0.9999.
16. The fastest printing of an integer was for the value 0. The slowest was for 32767.
17. The fastest printing of a float was for the value 1.0, and the slowest was for
1.7E38.
18. VAST_IIC_READ() and VAST_IIC_SEND() affect the LCD display.
19. The two numbers for "intvar = COMM(x, 1, 'a')" and the printing of single characters
to the COMM port(s) represent the measured time, which includes character transmission
overhead, with the number in parentheses indicating the actual execution time of the
instruction when it doesn't have to wait for the previously-sent character to
complete transmitting.
20. The two numbers for the comparison times (IF int < int, etc.) represent the TRUE and
FALSE conditions, respectively.
© 2002 Vesta Technology