Why not?
Here's one reason:
cmpthese -1, {
a=>q[
open O, '>', 'log';
for(1..10000){
print O chr(0)x80;
}
close O;
],
b=>q[
for(1..10000){
open O, '>>','log';
print O chr(0)x80;
close O;
}
]
};;
(warning: too few iterations for a reliable count)
s/iter b a
b 1.30 -- -99%
a 8.42e-003 15300% --
A second reason is that the first consumes almost no resource; whereas the second consumes prodigious amounts of it.
The times before and after the first:
a 5.546|5.343|0|0
a 5.546|5.343|0|0
And the second:
b 5.578|5.343|0|0
b 5.734|6.375|0|0
Whether you are just impacting every other process on your local server; or being billed for all that addition CPU & IO when running your process in the cloud; incurring 1000's of times more resource use in order to satisfy a dumb tool that is easily silenced is .... Its your dollar, you pick the adjective.
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.