I can't remember right now if Perl optimizes this in recent releases.
I don't think so - and same goes for raku, apparently.
On Ubuntu-20.04 (perl-5.32.0):
$ perl -le '$x = time;for (1..1000000000) {}; print time - $x;'
51
On Windows7 (perl-5.32.0):
C:\>perl -le "$x = time;for (1..1000000000) {}; print time - $x;"
13
The Windows box is about twice as fast as the Ubuntu box, so I'm not sure why the difference in this case is a factor of 4.
Anyway, thankfully perl has XS/Inline::C at hand to enable sane and efficient handling for cases such as these.
Cheers, Rob
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|