Reputation: 1314
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
?
Upvotes: 0
Views: 87
Reputation:
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.
Upvotes: 3