Merge CPUTime into JuliaLang
zouhairm opened this issue · 5 comments
This pretty useful. It would be nice to have it as part of the master branch.
I'm hesitant to do this as modern linear algebra libraries (OpenBLAS) have really good support for multi-threading, and this can lead to incorrect conclusions being drawn about timing since CPU time is summed across all child threads of a process:
julia> n = 1000; A = rand(n,n); B = rand(n,n);
julia> @time @CPUtime C = A*B; # matrix multiplication on a quad-core i7
elapsed CPU time: 0.178905 seconds
elapsed time: 0.045403309 seconds (8000488 bytes allocated)
See also JuliaLang/julia#10157. It might seem that a possible resolution would be counting only the CPU time used by the top-level process, but that can also be misleading - in this case it's probably 0. For multi-core machines, I still don't know a good way to reliably benchmark code when you've got other stuff going on in the background (the motivation of this package in the first place: http://stackoverflow.com/questions/24427185/measuring-elapsed-cpu-time-in-julia/). Oh well.
So unless you're running single-threaded code (scientific computing without any linear algebra??), the utility of this package is sort of nebulous, which is why I haven't bothered trying to register it with the Julia package manager. Putting it in Julia master would probably do more harm than help.
sounds reasonable. It might not be useful in the general sense, but definitely useful for the single threaded case.
But I understand what you mean about potentially doing more harm.
Might be nice to have registered on METADATA.jl so people can just do Pkg.add("CPUTime")
.
Fine fine, but caveat emptor.
since CPU time is summed across all child threads of a process
FWIW, I searched for a CPU time Julia library because this is the behavior I wanted (and expected from a "CPUTime").