Process.times is not implemented on Windows now. This is a proposal how to implement it.
CPU usage consumed by a process can be got by GetProcessTimes. It is easy to fill Process::Tms#utime and #stime. Just calling GetProcessTimes(GetCurrentProcess(), ....). I want to hear opinions about #cutime and #cstime.
The #cutime and #cstime values come from getrusage() with RUSAGE_CHILDREN on Unix. They include the resources used by not only direct children but also further descendants on Linux. POSIX just says "children of the current process" and doesn't notice whether they include the resources used by further descendants or not. The manpage of FreeBSD and macOS is same with that of POSIX. Does the word "children" in English include descendants in this context?
By the way I came up with two options.
GetProcessTimes just before [this line] and add up to a class variable of Crystal::System::Process.I prefer the former because most users, I guess, won't care about #cutime and #cstime.
In addition the latter is similar to but not same with that on Linux.
... most users, I guess, won't care about #cutime and #cstime.
Total CPU time printed by BenchMark is sum of utime, stime, cutime and cstime. Is it worth to support cutime and cstime of direct children?
Maybe none of this is worth supporting.
Let's do the same as Ruby and Python.
Oh wow, I had no idea that Python supported this!
Most helpful comment
Let's do the same as Ruby and Python.