Time a function: Difference between revisions

No edit summary
Line 1,752:
0.080 sec
-> 12</lang>
 
=={{header|Pike}}==
Shows CPU time used, not including any automatic gc passes. Explicit
calls to gc() are included though. This example uses the convenience
function gauge(), but it could also be done manually with
gethrvtime() in ms or ns resolution.
<lang Pike>
void get_some_primes()
{
int i;
while(i < 10000)
i = i->next_prime();
}
 
void main()
{
float time_wasted = gauge( get_some_primes() );
write("Wasted %f CPU seconds calculating primes\n", time_wasted);
}
</lang>
{{Out}}
<pre>
Wasted 0.014 CPU seconds calculating primes
</pre>
 
=={{header|PL/I}}==
Anonymous user