I am writing a perl script, and I need to achieve the same output as the linux "time" command, but without actually using the "time" command. Meaning I need to get the "real", "usr", "sys" times from a specific start time up to another point in time.
I have looked at the Time::HiRes
library, but I am new to perl and am not sure how to use it properly.
How can I achieve the same output as the "time" command using Time::HiRes
?
You can't. The breakdown of user and system time cannot be calculated from the elapsed wall time, which is the only information that Time::HiRes will give you.
You will need to use a module like BSD::Resource (specifically, the getrusage()
function) to get this information.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.