I assume you mean gmtime and localtime.

Unless this benchmark is fundamentally flawed, it seems gmtime is 2x faster than localtime. See perlfunc for more.
#!/usr/bin/perl -sw use strict; use Benchmark; our $ITERATIONS ||= 1e7; timethese($ITERATIONS, { gmtime => sub { my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday) = gmtime(time); }, localtime => sub { my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) += localtime(time); }, } ); __END__ $ perl 619744.pl Benchmark: timing 10000000 iterations of localtime, gmtime... localtime: 101 wallclock secs (51.07 usr + 45.89 sys = 96.96 CPU) @ 1 +03135.31/s (n=10000000) gmtime: 62 wallclock secs (29.76 usr + 27.94 sys = 57.70 CPU) @ 17 +3310.23/s (n=10000000)
#!/usr/bin/perl -sw use strict; use Benchmark; use Time::Local; our $ITERATIONS ||= 1e7; my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday) = gmtime(time); timethese($ITERATIONS, { timegm => sub { my $time = timegm($sec,$min,$hour,$mday,$mon, +$year); }, timelocal => sub { my $time = timelocal($sec,$min,$hour,$mday,$m +on,$year); }, } ); __END__ $ perl 619744.pl Benchmark: timing 10000000 iterations of timegm, timelocal... timegm: 95 wallclock secs (89.95 usr + 0.06 sys = 90.01 CPU) @ 11 +1098.77/s (n=10000000) timelocal: 811 wallclock secs (654.30 usr + 112.15 sys = 766.45 CPU) +@ 13047.17/s (n=10000000)
Update: Now comparing Time::Local functions.
--
print map{chr}unpack(q{A3}x24,q{074117115116032097110111116104101114032080101114108032104097099107101114})

In reply to Re: Timegm and timelocal by andreas1234567
in thread Timegm and timelocal by Chon-Ji

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.