Jump to content

Rate counter: Difference between revisions

→‎{{header|Raku}}: raku got faster in ten years, so bump difficulty
(→‎{{header|Raku}}: raku got faster in ten years, so bump difficulty)
Line 1,866:
sub factorial($n) { (state @)[$n] //= $n < 2 ?? 1 !! $n * factorial($n-1) }
 
runrate 10000100_000, { state $n = 1; factorial($n++) }
 
runrate 10000100_000, { state $n = 1; factorial($n++) }</syntaxhighlight>
{{out}}
<pre>Start time: 20132023-0304-08T2019T08:5723:02Z50.276418Z
End time: 20132023-0304-08T2019T08:5723:03Z54.716864Z
Elapsed time: 14.5467497440445313 seconds
Rate: 646522520.1726 per second
 
Start time: 20132023-0304-08T2019T08:5723:03Z54.726913Z
End time: 20132023-0304-08T2019T08:5723:04Z54.798238Z
Elapsed time: 0.7036318071324057 seconds
Rate: 142111402051.9848 per second</pre>
</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.
 
1,934

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.