OTHER CONTRIBUTIONS: GET/PUT PERFORMANCE

This example attempts to calculate the speed of capturing and redrawing the GET IMAGE and PUT IMAGE primitives. The example is configurable to identify the weight of various factors in the operations.

source compile sandbox issues? back to examples

SOURCE CODE ()

CONST width = 16
CONST height = 16

DIM timeLimit AS INTEGER

timeLimit = (TICKS PER SECOND) * 10

BITMAP ENABLE (16)
COLOR BORDER BLACK
CLS BLACK

VAR counter AS WORD = 0

LOCATE 0,0
PEN WHITE
PRINT "TESTING ON ";PEN(YELLOW);SCREEN WIDTH;"x";SCREEN HEIGHT;"x";SCREEN COLORS;PEN(WHITE)
PRINT "  FRAME : ";PEN(YELLOW);width;"x";height;PEN(WHITE)
PRINT "  DUR.  : ";PEN(YELLOW);(timeLimit / (TICKS PER SECOND));" secs";PEN(WHITE)
PRINT

background := NEW IMAGE(#width, #height)

TIMER = 0

DO
    GET IMAGE background FROM 0, 0
    PUT IMAGE background AT 0, 0
    INC counter
    EXIT IF TIMER > timeLimit
LOOP

PRINT "DONE"
PRINT

DIM fps AS FLOAT, frames AS FLOAT, time AS FLOAT
DIM pxs AS FLOAT, pixels AS FLOAT
px = 32 * 32
frames = counter
time = 10
pixels = px * frames

PRINT PEN(WHITE);" FRAMES   : "; frames
PRINT PEN(WHITE);" PIXELS   : "; pixels
PRINT PEN(WHITE);" FRAMES/S : "; PEN(YELLOW); INT( frames / time )

How to compile and run the example

The instructions here refer to compiling the example from the command line. For Microsoft Windows users we suggest using UGBASIC-IDE, which allows you to download and compile each single example with just one click.



Are instructions for your specific home computer / console missing? First of all, check if your computer is supported by clicking here. If so, since ugBASIC is a language which does not provide abstractions, it is possible that this example will not work on your target. If you think this is an issue, please click here.

Olivetti Prodest PC128, Thomson MO6

In order to compile the example, type this command on the command line:

Linux

ugbc.pc128op -O k7 -o contrib_get_put_performances.k7 contrib_get_put_performances.bas

Windows

ugbc.pc128op.exe -O k7 -o contrib_get_put_performances.k7 contrib_get_put_performances.bas

For Microsoft Windows users we suggest using UGBASIC-IDE, which allows you to download and compile this example with just one click.

TRS-80 Color Computer 3

In order to compile the example, type this command on the command line:

Linux

ugbc.coco3 -O bin -o contrib_get_put_performances.bin contrib_get_put_performances.bas

Windows

ugbc.coco3.exe -O bin -o contrib_get_put_performances.bin contrib_get_put_performances.bas

For Microsoft Windows users we suggest using UGBASIC-IDE, which allows you to download and compile this example with just one click.

Any problem?

If you have found a problem trying to run this example, if you think there is a bug or, more simply, you would like it to be improved, open an issue for this example on GitHub.
Thank you!

open an issue BACK TO EXAMPLES