Rate counter: Difference between revisions

no edit summary
(Add a simple C++ translation.)
No edit summary
Line 5:
* Run twenty seconds worth of jobs and/or two hundred jobs.
* Report at least three distinct times.
 
=={{header|bash}}==
This code stores the number of times the program '''task''' can complete in 20 seconds. It is two parts.
 
Part 1: file "foo.sh"
<lang bash>
#!/bin/bash
 
while : ; do
task && echo >> .fc
done
</lang>
 
Part 2:
<lang bash>
./foo.sh &
sleep 20 && killall -9 foo.sh
wc -l .fc
rm .fc
</lang>
 
=={{header|C}}==
Anonymous user