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.


In reply to Re: Timing a process (simple maths) by grinder
in thread Timing a process by ukndoit

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.