in reply to Timing a process
how would I turn that into x amount of hours, x amount of minutes, and x amount of seconds
Your approach is quite sound for any process that is going to take many seconds to complete. The Benchmark module is good for measuring different snippets of code that take milliseconds to run.
If your question is simply how to convert a large number of seconds into seconds, minutes, hours and beyond, you just have to take the modulo, and then divide by, the length of the interval you're interested in. The following code demonstrates the idea:
my $seconds = $duration % 60; $duration /= 60; my $minutes = $duration % 60; $duration /= 60; my $hours = $duration % 24; my $days = $duration;
That's only a rough sketch. You also have to deal with the rounding of the different division operations. It's much easier to get a module like Time::Duration to do it. You might also want to look at an old node of mine: Formatting elapsed time.
|
|---|