Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
It works fast and is tiny.
I beg to differ. It is both slow and verbose. DateTime is 10 times faster, and Date::Calc is 700 times faster!
use strict; use warnings; use DateTime; use Date::Calc qw (Add_Delta_DHMS); use Benchmark qw(cmpthese); my $dt = DateTime->new( year => 2011, month => 1, day => 1, hour => 0, minute => 0, second => 0, ); my ($year, $month, $day, $hour, $min, $sec) = (2011, 1, 1, 0, 0, 0); cmpthese( -1, { 'DateTime' => sub { $dt->add(hours => 1, minutes => 2, seconds => 3); }, 'Date::Calc' => sub { ($year, $month, $day, $hour, $min, $sec) = Add_Delta_DHMS($year, $month, $day, $hour, $min, $sec, 0, 1, 2 +, 3); }, 'tsk1979' => sub { my $lat = 23.438; my $slon = 68.000; my $elon = 90.000; my $clon = $slon; my $incrlon = 0.01; my $time = time; my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) + = localtime($time); my $incrtime = 1; my $printmon; my $printyear; while ($clon < $elon) { $printmon = $mon + 1; $printyear = $year + 1900; $clon = $clon + $incrlon; $time = $time + $incrtime; ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) += localtime($time); } }, } ); __END__ $ perl -l 883070.pl | tail -5 Rate tsk1979 DateTime Date::Calc tsk1979 339/s -- -90% -100% DateTime 3319/s 878% -- -100% Date::Calc 893673/s 263192% 26830% -- $
It is a good habit to Benchmark your code before making bold claims about its performance.
--
No matter how great and destructive your problems may seem now, remember, you've probably only seen the tip of them. [1]

In reply to Re: Solution found! by andreas1234567
in thread Simple date and time manipulation by tsk1979

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, 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, 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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others musing on the Monastery: (4)
    As of 2019-07-18 07:36 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found

      Notices?