Time a function: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
Kinitawowi (talk | contribs) No edit summary |
||
Line 2,795: | Line 2,795: | ||
{{out}} |
{{out}} |
||
<pre>3</pre> |
<pre>3</pre> |
||
=={{header|ZX Spectrum Basic}}== |
|||
The ZX Spectrum has very little in the way of timing functionality; its best clock is the three-byte FRAMES variable, which starts at zero when the system is turned on and updates every time the ULA refreshes the screen, giving a granularity of one fiftieth of a second. As the system cannot multitask, a difference between the start and end time is as good as we can get; certain actions, most notably operating the system BEEPer, temporarily stop the counter. |
|||
<syntaxhighlight lang="zxbasic"> |
|||
1 DEF FN t()=(PEEK 23672+256*PEEK 23673+65536*PEEK 23674)/50 |
|||
10 LET time=FN t() |
|||
20 PRINT ASN 0.5 |
|||
30 PRINT FN t()-time</syntaxhighlight> |
|||
{{out}} |
|||
<pre>0.52359878 |
|||
0.22 |
|||
0 OK, 30:1</pre> |