Rate counter: Difference between revisions

Line 845:
return times;
}</lang>
 
=={{header|Julia}}==
<lang julia>dosomething() = sleep(abs(randn()))
 
function runNsecondsworthofjobs(N)
times = Vector{Float64}()
totaltime = 0
runcount = 0
while totaltime < N
t = @elapsed(dosomething())
push!(times, t)
totaltime += t
runcount += 1
end
println("Ran job $runcount times, for total time of $totaltime seconds.")
println("Average time per run was $(sum(times)/length(times)) seconds.")
println("Individual times of the jobs in seconds were:")
for t in times
println(" $t")
end
end
 
runNsecondsworthofjobs(5)
</lang>{{output}}<pre>
Ran job 5 times, for total time of 5.215301074 seconds.
Average time per run was 1.0430602148 seconds.
Individual times of the jobs in seconds were:
1.901202753
0.706044625
0.485377196
0.489283165
1.633393335
</pre>
 
 
=={{header|Kotlin}}==
4,102

edits