R
RedGrittyBrick
Purl said:RedGrittyBrick said:Naji wrote:
(snipped)
if ((time - (stat 'filename')[9]) < 24*60*60) {
print "recently modified/n";
}
Both you and readers will be as surprised as I by benchmark results.
You are wrong, after years of your peculiar postings I'm hardly
surprised by anything you might post, however surreal.
Most people would understand that the reason I used "time" and
"24*60*60" were to make comprehension easy for Naji who is "rather new
to Perl".
Unless you are an obsessive, normal priorities are:
1) Make it produce correct results.
2) If performance is a problem, optimise.
Initially, I became curious if use of time and multiplication would
be less efficient than use of $^T and 86400 to compare Epoch seconds.
Test results don't disclose this but rather a real surprise related to use
of Perl's default time function.
Purl Gurl
I plugged these codes into benchmark:
sub Time
{
timethese (100000,
It is very unlikely that Naji has 100,000 attachments that need
monitoring so tweaking performance seems a bit overkill at this stage.
Even if he did have that many, 13 elapsed seconds for 100,000 tests
wouldn't be worth worrying about for the purposes he describes.
{
'Brick' =>
'if (time > 24*60*60)
{ $out1 = "true"; } ',
The statement 'if (time > 24*60*60) ...' bears so little relation to my
code or any useful code that I wonder why anyone might think it
worthwhile to benchmark it. time() has been greater than 24*60*60 since
before Perl existed!
I rather suspect that you took out the stat() simply because in real
world code, the time to perform stat() swamps everything else. This
makes the benchmark pretty futile in my view.
Your code reminds me of people who tried to benchmark
for i=1 to 100,000
end for
only to find the compiler had optimised it to
NOP
Generally I trust compilers to do obvious optimisation for me.
As a general principle, I usually consider slow clear code to be
'better' than fast obfuscated code.
<snip: useless benchmark of purposeless code>