Rate counter: Difference between revisions
Added Chipmunk Basic
(Added Chipmunk Basic) |
|||
(3 intermediate revisions by 3 users not shown) | |||
Line 551:
return 0;
}</syntaxhighlight>
=={{header|Chipmunk Basic}}==
{{works with|Chipmunk Basic|3.6.4}}
<syntaxhighlight lang="vbnet">100 cls
110 for i = 1 to 3
120 gosub 170
130 next i
140 i = 200
150 gosub 170
160 end
170 'function timeit
180 iter = 0
190 starter = timer
200 while true
210 iter = iter+1
220 if timer >= starter+i then exit while
230 wend
240 print iter;" iteraciones en ";i;" milisegundo";
250 if i > 1 then print "s" else print ""
260 return</syntaxhighlight>
=={{header|Common Lisp}}==
Line 801 ⟶ 821:
theJob()
})</syntaxhighlight>
=={{header|EasyLang}}==
[https://easylang.dev/show/#cod=RYzLCsIwEEX3+YpDF+IDyygUV+m/hDZCIA9JB8G/l4SKm8sc5ty7lFgqDxFTMi6H5NQbYIne1XZUt3KxyHhvlMrbMwmTdCnUJfqmNArPLs/7c+9aOo0tFMv22TQkvxdUmPnprxqychMRzhyVKyonDgykbfiPCBY1Pq/mCw== Run it]
<syntaxhighlight>
color 700
on animate
clear
rad += 0.2
move 50 50
circle rad
if rad > 50
rad = 0
.
t = systime
if t0 > 0
print 1000 * (t - t0) & " ms"
.
t0 = t
end
</syntaxhighlight>
{{out}}
<pre>
17.00 ms
17.00 ms
16.00 ms
.
.
</pre>
=={{header|Erlang}}==
Line 1,866 ⟶ 1,914:
sub factorial($n) { (state @)[$n] //= $n < 2 ?? 1 !! $n * factorial($n-1) }
runrate
runrate
{{out}}
<pre>Start time:
End time:
Elapsed time:
Rate:
Start time:
End time:
Elapsed time: 0.
Rate:
</pre>
The <tt>Instant</tt> type in Perl 6 is defined to be based on TAI seconds, and represented with rational numbers that are more than sufficiently accurate to represent your clock's accuracy. The actual accuracy will depend on your clock's accuracy (even if you don't have an atomic clock in your kitchen, your smartphone can track various orbiting atomic clocks, right?) modulo the vagaries of returning the atomic time (or unreasonable facsimile) via system calls and library APIs.
Line 2,406 ⟶ 2,455:
Note that, in an attempt to obtain more meaningful times, I've called the function 1 million times compared to just one in the Kotlin example which uses a more accurate timer.
<syntaxhighlight lang="
var benchmark = Fn.new { |n, func, arg, calls|
|