How to resolve the algorithm Rate counter step by step in the BBC BASIC programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Rate counter step by step in the BBC BASIC programming language
Table of Contents
Problem Statement
Of interest is the code that performs the actual measurements. Any other code (such as job implementation or dispatching) that is required to demonstrate the rate tracking is helpful, but not the focus. Multiple approaches are allowed (even preferable), so long as they can accomplish these goals: Be aware of the precision and accuracy limitations of your timing mechanisms, and document them if you can. See also: System time, Time a function
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Rate counter step by step in the BBC BASIC programming language
Source code in the bbc programming language
PRINT "Method 1: Calculate reciprocal of elapsed time:"
FOR trial% = 1 TO 3
start% = TIME
PROCtasktomeasure
finish% = TIME
PRINT "Rate = "; 100 / (finish%-start%) " per second"
NEXT trial%
PRINT '"Method 2: Count completed tasks in one second:"
FOR trial% = 1 TO 3
runs% = 0
finish% = TIME + 100
REPEAT
PROCtasktomeasure
IF TIME < finish% runs% += 1
UNTIL TIME >= finish%
PRINT "Rate = "; runs% " per second"
NEXT trial%
END
REM This is an example, replace with the task you want to measure
DEF PROCtasktomeasure
LOCAL i%
FOR i% = 1 TO 1000000
NEXT
ENDPROC
You may also check:How to resolve the algorithm Detect division by zero step by step in the NS-HUBASIC programming language
You may also check:How to resolve the algorithm Even or odd step by step in the M2000 Interpreter programming language
You may also check:How to resolve the algorithm Approximate equality step by step in the Ada programming language
You may also check:How to resolve the algorithm Anonymous recursion step by step in the Axiom programming language
You may also check:How to resolve the algorithm Arrays step by step in the Monte programming language