Time a function: Difference between revisions
Added Quackery.
(→Insitux: implementation) |
(Added Quackery.) |
||
Line 2,378:
[2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0]
using ''qsort()'' from [[Quicksort#Python|Quicksort]]. Timings show that the implementation of ''qsort()'' has quadratic dependence on sequence length ''N'' for already sorted sequences (instead of ''O(N*log(N))'' in average).
=={{header|Quackery}}==
<code>time</code> returns system time since Unix epoch in microseconds, but is not reliable to the microsecond, so we are using millisecond granularity. Process time is not available.
<syntaxhighlight lang="Quackery"> [ time ]'[ do
time swap - 1000 / ] is time: ( --> n )
time: [ 0 314159 times 1+ echo ]
cr cr
say "That took about " echo say " milliseconds."</syntaxhighlight>
{{out}}
<pre>314159
That took about 392 milliseconds.
</pre>
=={{header|R}}==
|