"Chas. Owens" <chas.ow...@gmail.com> writes:

> You can use printf or sprintf to control the format, but what you are doing
> is called profiling and it is better to use an actual profiler. Take a look
> at Devel::NYTProf
>
> http://search.cpan.org/~timb/Devel-NYTProf-6.04/lib/Devel/NYTProf.pm
>
> https://www.perl.org/about/whitepapers/perl-profiling.html
>
> On Wed, May 24, 2017, 22:12 SSC_perl <p...@surfshopcart.com> wrote:
>
>>         I’m timing sub routines to get an idea of where my scripts spend
>> the most of their time.  This is an example of what I’m doing:
>>
>> use Time::HiRes qw( clock );
>> my $clock0 = clock();
>> ... # Do something.
>> my $clock1 = clock();
>> my $clockd = $clock1 - $clock0;
>>
>>         I’m getting values like $clock1 = 0.030259 and $clock0 =
>> 0.030212.  However, instead of $clockd being 0.000047, it’s returning
>> 4.70000000000019e-05.  I take it that’s exponential notation (?) but it’s
>> actually more difficult to read than the regular number.  Is there a way to
>> get it to print out differently?
>>
>> Thanks,
>> Frank
>> --
>> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
>> For additional commands, e-mail: beginners-h...@perl.org
>> http://learn.perl.org/
>>
>>
>>

There's a method provided by Time::HiRes called 'interval' or the like
which might give you nicer output.  At least it saves you the
subtraction.


Using a profiler is not always better; it depends on what the program
does.  With time intervals this small, it's probably better.


-- 
"Didn't work" is an error.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to