in reply to Re^4: Play Template
in thread Play Template
Unannounced update. Pathetic, "performance doesn't matter" missive.
Now I must crush you.
Fail!
I'd guess, by looking at your command line invocation (c:\test>ROvCONST.pl), that you suffer under the burden of some flavor of Windows for which Readonly::XS is not available or is difficult to install.
C:\Perl64\packages>gunzip Readonly-XS-1.05.tar.gz C:\Perl64\packages>tar -xvf Readonly-XS-1.05.tar Readonly-XS-1.05/ Readonly-XS-1.05/Changes Readonly-XS-1.05/Makefile.PL Readonly-XS-1.05/MANIFEST Readonly-XS-1.05/META.yml Readonly-XS-1.05/ppport.h Readonly-XS-1.05/README Readonly-XS-1.05/t/ Readonly-XS-1.05/t/test.t Readonly-XS-1.05/XS.pm Readonly-XS-1.05/XS.xs C:\Perl64\packages>cd Readonly-XS-1.05 C:\Perl64\packages\Readonly-XS-1.05>makefile Checking if your kit is complete... Looks good Writing Makefile for Readonly::XS C:\Perl64\packages\Readonly-XS-1.05>nmake Microsoft (R) Program Maintenance Utility Version 9.00.21022.08 Copyright (C) Microsoft Corporation. All rights reserved. cp XS.pm blib\lib\Readonly\XS.pm C:\perl64\bin\perl.exe C:\Perl64\lib\ExtUtils\xsubpp -typemap + C:\Perl64\lib\ExtUtils\typemap XS.xs > XS.xsc && C:\perl cl -c -I. -nologo -GF -W3 -MD -Zi -DNDEBUG -Ox -GL -fp:preci +se -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT -DWIN6 XS.c Running Mkbootstrap for Readonly::XS () C:\perl64\bin\perl.exe -MExtUtils::Command -e "chmod" -- 644 X +S.bs C:\perl64\bin\perl.exe -MExtUtils::Mksymlists -e "Mksymlists( +'NAME'=>\"Readonly::XS\", 'DLBASE' => 'XS', 'DL_FUNCS' => link -out:blib\arch\auto\Readonly\XS\XS.dll -dll -nologo -node +faultlib -debug -opt:ref,icf -ltcg -libpath:"C:\Perl64\li Creating library blib\arch\auto\Readonly\XS\XS.lib and object blib\ +arch\auto\Readonly\XS\XS.exp Generating code Finished generating code if exist blib\arch\auto\Readonly\XS\XS.dll.manifest mt -nologo + -manifest blib\arch\auto\Readonly\XS\XS.dll.manifest -out if exist blib\arch\auto\Readonly\XS\XS.dll.manifest del blib\a +rch\auto\Readonly\XS\XS.dll.manifest C:\perl64\bin\perl.exe -MExtUtils::Command -e "chmod" -- 755 b +lib\arch\auto\Readonly\XS\XS.dll C:\perl64\bin\perl.exe -MExtUtils::Command -e "cp" -- XS.bs bl +ib\arch\auto\Readonly\XS\XS.bs C:\perl64\bin\perl.exe -MExtUtils::Command -e "chmod" -- 644 b +lib\arch\auto\Readonly\XS\XS.bs C:\Perl64\packages\Readonly-XS-1.05>nmake test Microsoft (R) Program Maintenance Utility Version 9.00.21022.08 Copyright (C) Microsoft Corporation. All rights reserved. C:\perl64\bin\perl.exe "-MExtUtils::Command::MM" "-e" "test_ha +rness(0, 'blib\lib', 'blib\arch')" t/*.t t/test.t .. ok All tests successful. Files=1, Tests=10, 0 wallclock secs ( 0.06 usr + 0.06 sys = 0.13 CP +U) Result: PASS C:\Perl64\packages\Readonly-XS-1.05>nmake install Microsoft (R) Program Maintenance Utility Version 9.00.21022.08 Copyright (C) Microsoft Corporation. All rights reserved. Files found in blib\arch: installing files in blib\lib into architectu +re dependent library tree Installing C:\Perl64\site\lib\auto\Readonly\XS\XS.bs Installing C:\Perl64\site\lib\auto\Readonly\XS\XS.dll Installing C:\Perl64\site\lib\auto\Readonly\XS\XS.exp Installing C:\Perl64\site\lib\auto\Readonly\XS\XS.lib Installing C:\Perl64\site\lib\auto\Readonly\XS\XS.pdb Installing C:\Perl64\site\lib\Readonly\XS.pm Appending installation info to C:\Perl64\lib/perllocal.pod
Fail!
except that this imposes no performance penalty over a simple my() declaration:
Fail! Note that constant is actually faster than literals:
#! perl -slw use strict; use Benchmark qw[ cmpthese ]; use constant { TRUE => 1, FALSE => 0, VALUE => 12345, }; use Readonly; Readonly::Scalar my $true => 1; Readonly::Scalar my $false => 0; Readonly::Scalar my $value => 12345; sub usingConstant { for( 1 .. 1e6 ) { if( TRUE ) { my $sum = VALUE * VALUE; } if( FALSE ) { ;## Never called } } } sub usingLiterals { for( 1 .. 1e6 ) { if( 1 ) { my $sum = 12345 * 12345; } if( 0 ) { ;## Never called } } } sub usingReadonly { for( 1 .. 1e6 ) { if( $true ) { my $sum = $value * $value; } if( $false ) { ;## Never called } } } cmpthese -1, { const => sub{ usingConstant() }, literals => sub{ usingLiterals() }, Readonly => sub{ usingReadonly() }, };
c:\test>ROvCONST.pl Rate Readonly literals const Readonly 4.06/s -- -44% -49% literals 7.21/s 78% -- -9% const 7.90/s 95% 10% --
In fact, I have slowly come to define most of my variables as scalars -- scalar hashrefs, scalar arrayrefs -- rather than hashes and arrays.
Fail!
Look up who said "Programs are more readable if different things look different.". And when. And why.
Or buy|rent a faster box, which might well be a cheaper solution than wasting my time.
Fail!
Take a look around you. In the early noughties, that attitude flew because clockspeeds increased from 400 MHz (1999) through to 3.3GHz in 2003. But it has stagnated for the last 7 years. Sure, they're managing to get through more instructions per clock, but only if the pipelines don't stall.
Throwing faster hardware at self-induced performance issues is no longer an option. Now, the options are threading, clustering, or map-reduce. All of which are far more complicated than simply avoiding, avoidable premature pessimisations
Let's discuss another aspect of the node.
Nothing else in the node was even vaguely of interest to me me. Nor anyone else it seems.
My play scripts generally exercise at most a dozen lines of code and exit almost before I touch Enter.
All that O'Woe(*) to try out a "dozen lines of code"?
(*)Order of Worshipful over-engineers.
|
|---|