SlideShare uma empresa Scribd logo
1 de 51
Benchmarking Perl
           brian d foy
  Stonehenge Consulting Ser vices
        March 14, 2006
        Chicago UniForum
Know where you are
 “A benchmark is a point of reference for a
measurement. The term originates from the
 chiseled horizontal marks that sur veyors
made into which an angle-iron could be placed
   to bracket (bench) a leveling rod, thus
    ensuring that the leveling rod can be
 repositioned in the exact same place in the
                   future.”
                   http:/
                        /en.wikipedia.org/wiki/Benchmark
Single Points
Multiple
 Points
Nobody is ferpect

It’s only relative
It has to be the same answer next time
If something changes, the reference is
meaningless
Computer Benchmarks

Standard Performance Evaluation
Corporation (SPEC)
 CPU (2000, 95, 92)
 Graphics
 Web ser vers

                      http://www.spec.org/
All Things Being Equal...

 There are lies, damned lies, and
 benchmarks
 Everyone has an agenda
 You don’t run testbeds as production
 Skepticism wins the day
Language Shootout
Benchmarking programming languages?
How can we benchmark a programming language?
We can't - we benchmark programming language
implementations.

How can we benchmark language implementations?
We can't - we measure particular programs.

                 http:/
                      /shootout.alioth.debian.org/
Performance

  A major factor in determining the overall
  productivity of a system, performance is
primarily tied to availability, throughput and
                response time.


         http://www.comptia.org/sections/ssg/glossary.aspx
Performance (2)
      A performance comprises
          an event in which
        generally one group of
          people behave in a
          particular way for
       another group of people


    http://en.wikipedia.org/wiki/Performance
Performance (3)
         “Your investment's
         activity over time.
         Past performance
         does not guarantee
         future results.”

             My accountant
How many
 metrics
 can you
  name?
Availability Disk Use
 Concurrent Users CPU Time
Completion Time Memory Use
   Uptime Bandwidth Use
Net work Lag Responsiveness
        Binary Size
Programmer
   Time
Power

  Speed

Ease of use
Pick Any Two
You haven’t said “Perl”
Perl is just a programming language
It’s a High Level Language
Measure Perl the same as other things
Measure Perl against itself
Compare the results
TIMTOWTMI
It’s not
  just
 speed
Memory Use
use Devel::Size qw(size total_size);

my $size = size(quot;A stringquot;);

my @foo = (1, 2, 3, 4, 5);
my $other_size = size(@foo);

my $foo = {
        a => [1, 2, 3],
        b => {a => [1, 3, 4]}
       };
my $total_size = total_size($foo);
Memory Use (2)

use Devel::Peek;
Dump( $a );
Dump( $a, 5 );
DumpArray( 5, $a, $b, ... );
mstat quot;Point 5quot;;




                Need PERL_DEBUG_MSTATS
Database query time
           $ DBI_PROFILE=2 db_script


  DBI::Profile: 0.001015s (5 calls) db_script @ YYYY-MM-DD HH:MM:SS
  '' =>
      0.000024s / 2 = 0.000012s avg (first 0.000015s, min 0.000009s,
max 0.000015s)
  'SELECT mode,size,name FROM table' =>
      0.000991s / 3 = 0.000330s avg (first 0.000678s, min 0.000009s,
max 0.000678s)
Benchmark.pm
 comes with
    Perl...
...and it sux...
 Sux : Sucks :: Kwalitee : Quality
Common misuse
use Benchmark 'cmpthese';

my @long    = ('a' .. 'z', '');

my $iter = shift || -1;

cmpthese(
    $iter,{
        long_block_ne    =>   q{grep   {$_ ne ''}   @long},
        long_block_len   =>   q{grep   {length}     @long},
        long_bare_ne     =>   q{grep   $_ ne '',    @long},
        long_bare_len    =>   q{grep   length,      @long},
    }
);




           http://www.perlmonks.org/index.pl?node_id=536503
What’s wrong with this picture?
   Rate                      bare_ne   block_len   block_ne   bare_len
long_bare_ne     3635361/s      --         -6%        -6%         -8%
long_block_len   3869054/s      6%          --        -0%         -2%
long_block_ne    3872708/s      7%          0%         --         -2%
long_bare_len    3963159/s      9%          2%         2%          --
Mac OS X.4.5
                 15” G4 Powerbook
                      perl5.8.4
                    Rate   bare_len   bare_ne   block_ne   block_len
long_bare_len 2805822/s          --       -0%        -1%         -3%
long_bare_ne   2805822/s         0%        --        -1%         -3%
long_block_ne 2840569/s          1%        1%         --         -2%
long_block_len 2885232/s         3%        3%         2%          --
This is perl, v5.8.4 built for darwin-2level

Summary of my perl5 (revision 5 version 8 subversion 4) configuration:
  Platform:
    osname=darwin, osvers=7.3.1, archname=darwin-2level
    uname='darwin albook.local 7.3.1 darwin kernel version 7.3.1: mon mar 22
21:48:41 pst 2004; root:xnuxnu-517.4.12.obj~2release_ppc power macintosh powerpc '
    config_args=''
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-pipe -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-
aliasing',
    optimize='-Os',
    cppflags='-no-cpp-precomp -pipe -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-
strict-aliasing'
    ccversion='', gccversion='3.3 20030304 (Apple Computer, Inc. build 1640)',
gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags =''
    libpth=/usr/lib
    libs=-ldbm -ldl -lm -lc
    perllibs=-ldl -lm -lc
    libc=/usr/lib/libc.dylib, so=dylib, useshrplib=false, libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dyld.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup'
Millions
 of times
a second?
Do something useful
use Benchmark 'cmpthese';

our @long   = ('a' .. 'z', '');

my $iter = shift || -1;

cmpthese(
    $iter,{
        long_block_ne     =>   q{my   @array   =   grep   {$_ ne ''}   @long},
        long_block_len    =>   q{my   @array   =   grep   {length}     @long},
        long_bare_ne      =>   q{my   @array   =   grep   $_ ne '',    @long},
        long_bare_len     =>   q{my   @array   =   grep   length,      @long},
    }
);
These numbers make sense

                  Rate   block_ne   block_len   bare_ne   bare_len
long_block_ne 31210/s          --         -3%       -3%        -5%
long_block_len 32119/s         3%          --       -0%        -2%
long_bare_ne   32237/s         3%          0%        --        -2%
long_bare_len 32755/s          5%          2%        2%         --
Don’t Trust!
                                 Verify!

use Benchmark 'cmpthese';

our @long   = ('a' .. 'z', 0 .. 10_000, '');

my $iter = shift || -1;

cmpthese(
    $iter,{
        long_block_ne     =>   q{my   @array   =   grep   {$_ ne ''}   @long},
        long_block_len    =>   q{my   @array   =   grep   {length}     @long},
        long_bare_ne      =>   q{my   @array   =   grep   $_ ne '',    @long},
        long_bare_len     =>   q{my   @array   =   grep   length,      @long},
    }
);
It takes longer to do more
                 Rate   bare_ne   block_ne   block_len   bare_len
long_bare_ne   59.8/s        --        -1%         -2%        -3%
long_block_ne 60.4/s         1%         --         -1%        -3%
long_block_len 60.9/s        2%         1%          --        -2%
long_bare_len 61.9/s         4%         3%          2%         --
Theory of Measurement

 Obser vation changes the universe
 Nothing is objective
 Tools have inherent uncertainities
Precision
     is
repeatability
Accuracy
      is
 getting the
right answer
precision != accuracy
you
want
both
Benchmark.pm’s
      benchmark
Uses a null loop as a control
sub { }
It’s just a timer
Subtracts the null loop time
Introduces an error of about 7%
$ time perl script.pl

real   0m0.293s
user   0m0.130s
sys    0m0.036s



                  http://ppt.perl.org/
The map is not the terrain

   my @selected   = grep { ... } @array;
             ()   = grep { ... } @array;
   my @selected   =              @array;
   my @selected   =             ( ... );
   my @selected                        ;
$ perl -MO=Concise -e 'grep { lc } @array'

a   <@> leave[1 ref] vKP/REFC ->(end)
1      <0> enter ->2
2      <;> nextstate(main 2 -e:1) v ->3
7      <|> grepwhile(other->8)[t4] vK/1 ->a
6         <@> grepstart K*/2 ->7
3            <0> pushmark s ->4
-            <1> null lK/1 ->4
-               <1> null sK/1 ->7
-                  <@> scope sK ->7
-                     <0> ex-nextstate v ->8
9                     <1> lc[t2] sK/1 ->-
-                        <1> ex-rv2sv sK/1 ->9
8                           <$> gvsv(*_) s ->9
5            <1> rv2av[t3] lKM/1 ->6
4               <$> gv(*array) s ->5
$ perl -MO=Concise -e '() = grep { lc } @array'

d   <@> leave[1 ref] vKP/REFC ->(end)
1      <0> enter ->2
2      <;> nextstate(main 2 -e:1) v ->3
c      <2> aassign[t5] vKS/COMMON ->d
-         <1> ex-list lK ->b
3            <0> pushmark s ->4
8            <|> grepwhile(other->9)[t4] lK/1 ->b
7               <@> grepstart lK*/2 ->8
4                  <0> pushmark s ->5
-                  <1> null lK/1 ->5
-                     <1> null sK/1 ->8
-                        <@> scope sK ->8
-                            <0> ex-nextstate v ->9
a                            <1> lc[t2] sK/1 ->-
-                               <1> ex-rv2sv sK/1 ->a
9                                  <$> gvsv(*_) s ->a
6                  <1> rv2av[t3] lKM/1 ->7
5                     <$> gv(*array) s ->6
-         <1> ex-list lK ->c
b            <0> pushmark s ->c
-            <0> stub lPRM* ->-
$ perl -MO=Concise -e 'my @selected = grep { lc } @array'

e   <@> leave[1 ref] vKP/REFC ->(end)
1      <0> enter ->2
2      <;> nextstate(main 2 -e:1) v ->3
d      <2> aassign[t6] vKS ->e
-         <1> ex-list lK ->b
3            <0> pushmark s ->4
8            <|> grepwhile(other->9)[t5] lK/1 ->b
7               <@> grepstart lK*/2 ->8
4                  <0> pushmark s ->5
-                  <1> null lK/1 ->5
-                     <1> null sK/1 ->8
-                        <@> scope sK ->8
-                            <0> ex-nextstate v ->9
a                            <1> lc[t3] sK/1 ->-
-                               <1> ex-rv2sv sK/1 ->a
9                                  <$> gvsv(*_) s ->a
6                  <1> rv2av[t4] lKM/1 ->7
5                     <$> gv(*array) s ->6
-         <1> ex-list lK ->d
b            <0> pushmark s ->c
c            <0> padav[@selected:2,3] lRM*/LVINTRO ->d
“Premature
optimization
    is the
  root of all
     evil”  Tony Hoare
What
    do I
benchmark?
Find the bad parts

Profile the application first
Find out who’s taking all the time/
memory/net work
Compare situations
Fix that first
perl -d:SmallProf script
Better
algorithms
 do better
Summary
Decide what is important to you
Realize you have bias
Report the situation
Don’t turn off your brain
Make predictions that you can verify
Further Reading

 “Benchmarking”, The Perl Journal #11,
 http://www.pair.com/~comdog/Articles/benchmark.1_4.txt
 “Wasting Time Thinking About Wasted Time”,
 http://www.perlmonks.org/?node_id=393128

“Profiling in Perl”,
http://www.ddj.com/documents/s=1498/ddj0104pl/

Mais conteúdo relacionado

Mais procurados

The Perl6 Type System
The Perl6 Type SystemThe Perl6 Type System
The Perl6 Type Systemabrummett
 
The Joy of Smartmatch
The Joy of SmartmatchThe Joy of Smartmatch
The Joy of SmartmatchAndrew Shitov
 
Zend Certification Preparation Tutorial
Zend Certification Preparation TutorialZend Certification Preparation Tutorial
Zend Certification Preparation TutorialLorna Mitchell
 
Design Patterns in PHP5
Design Patterns in PHP5 Design Patterns in PHP5
Design Patterns in PHP5 Wildan Maulana
 
Zend Framework 2 : Dependency Injection
Zend Framework 2 : Dependency InjectionZend Framework 2 : Dependency Injection
Zend Framework 2 : Dependency InjectionAbdul Malik Ikhsan
 
The Art Of Readable Code
The Art Of Readable CodeThe Art Of Readable Code
The Art Of Readable CodeBaidu, Inc.
 
Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Kang-min Liu
 
PHP Traits
PHP TraitsPHP Traits
PHP Traitsmattbuzz
 
Can't Miss Features of PHP 5.3 and 5.4
Can't Miss Features of PHP 5.3 and 5.4Can't Miss Features of PHP 5.3 and 5.4
Can't Miss Features of PHP 5.3 and 5.4Jeff Carouth
 
The art of readable code (ch1~ch4)
The art of readable code (ch1~ch4)The art of readable code (ch1~ch4)
The art of readable code (ch1~ch4)Ki Sung Bae
 
WordCamp Portland 2018: PHP for WordPress
WordCamp Portland 2018: PHP for WordPressWordCamp Portland 2018: PHP for WordPress
WordCamp Portland 2018: PHP for WordPressAlena Holligan
 
Mocking Dependencies in PHPUnit
Mocking Dependencies in PHPUnitMocking Dependencies in PHPUnit
Mocking Dependencies in PHPUnitmfrost503
 
PHPCon 2016: PHP7 by Witek Adamus / XSolve
PHPCon 2016: PHP7 by Witek Adamus / XSolvePHPCon 2016: PHP7 by Witek Adamus / XSolve
PHPCon 2016: PHP7 by Witek Adamus / XSolveXSolve
 
Wx::Perl::Smart
Wx::Perl::SmartWx::Perl::Smart
Wx::Perl::Smartlichtkind
 

Mais procurados (20)

The Perl6 Type System
The Perl6 Type SystemThe Perl6 Type System
The Perl6 Type System
 
Perl6 in-production
Perl6 in-productionPerl6 in-production
Perl6 in-production
 
The Joy of Smartmatch
The Joy of SmartmatchThe Joy of Smartmatch
The Joy of Smartmatch
 
Perl6 one-liners
Perl6 one-linersPerl6 one-liners
Perl6 one-liners
 
Zend Certification Preparation Tutorial
Zend Certification Preparation TutorialZend Certification Preparation Tutorial
Zend Certification Preparation Tutorial
 
Design Patterns in PHP5
Design Patterns in PHP5 Design Patterns in PHP5
Design Patterns in PHP5
 
Zend Framework 2 : Dependency Injection
Zend Framework 2 : Dependency InjectionZend Framework 2 : Dependency Injection
Zend Framework 2 : Dependency Injection
 
The Art Of Readable Code
The Art Of Readable CodeThe Art Of Readable Code
The Art Of Readable Code
 
Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)
 
PHP Traits
PHP TraitsPHP Traits
PHP Traits
 
Can't Miss Features of PHP 5.3 and 5.4
Can't Miss Features of PHP 5.3 and 5.4Can't Miss Features of PHP 5.3 and 5.4
Can't Miss Features of PHP 5.3 and 5.4
 
Perl6 grammars
Perl6 grammarsPerl6 grammars
Perl6 grammars
 
The art of readable code (ch1~ch4)
The art of readable code (ch1~ch4)The art of readable code (ch1~ch4)
The art of readable code (ch1~ch4)
 
PHP Scripting
PHP ScriptingPHP Scripting
PHP Scripting
 
Dsl
DslDsl
Dsl
 
WordCamp Portland 2018: PHP for WordPress
WordCamp Portland 2018: PHP for WordPressWordCamp Portland 2018: PHP for WordPress
WordCamp Portland 2018: PHP for WordPress
 
Mocking Dependencies in PHPUnit
Mocking Dependencies in PHPUnitMocking Dependencies in PHPUnit
Mocking Dependencies in PHPUnit
 
PHP and MySQL
PHP and MySQLPHP and MySQL
PHP and MySQL
 
PHPCon 2016: PHP7 by Witek Adamus / XSolve
PHPCon 2016: PHP7 by Witek Adamus / XSolvePHPCon 2016: PHP7 by Witek Adamus / XSolve
PHPCon 2016: PHP7 by Witek Adamus / XSolve
 
Wx::Perl::Smart
Wx::Perl::SmartWx::Perl::Smart
Wx::Perl::Smart
 

Semelhante a Benchmarking Perl performance and memory usage

Ruby on Rails Intro
Ruby on Rails IntroRuby on Rails Intro
Ruby on Rails Introzhang tao
 
Being functional in PHP (PHPDay Italy 2016)
Being functional in PHP (PHPDay Italy 2016)Being functional in PHP (PHPDay Italy 2016)
Being functional in PHP (PHPDay Italy 2016)David de Boer
 
Rooted 2010 ppp
Rooted 2010 pppRooted 2010 ppp
Rooted 2010 pppnoc_313
 
Fpga 06-data-types-system-tasks-compiler-directives
Fpga 06-data-types-system-tasks-compiler-directivesFpga 06-data-types-system-tasks-compiler-directives
Fpga 06-data-types-system-tasks-compiler-directivesMalik Tauqir Hasan
 
Tips on how to improve the performance of your custom modules for high volume...
Tips on how to improve the performance of your custom modules for high volume...Tips on how to improve the performance of your custom modules for high volume...
Tips on how to improve the performance of your custom modules for high volume...Odoo
 
String Comparison Surprises: Did Postgres lose my data?
String Comparison Surprises: Did Postgres lose my data?String Comparison Surprises: Did Postgres lose my data?
String Comparison Surprises: Did Postgres lose my data?Jeremy Schneider
 
Joker 2015 - Валеев Тагир - Что же мы измеряем?
Joker 2015 - Валеев Тагир - Что же мы измеряем?Joker 2015 - Валеев Тагир - Что же мы измеряем?
Joker 2015 - Валеев Тагир - Что же мы измеряем?tvaleev
 
Степан Кольцов — Rust — лучше, чем C++
Степан Кольцов — Rust — лучше, чем C++Степан Кольцов — Rust — лучше, чем C++
Степан Кольцов — Rust — лучше, чем C++Yandex
 
Easing the Complex with SPBench framework
Easing the Complex with SPBench frameworkEasing the Complex with SPBench framework
Easing the Complex with SPBench frameworkadriano1mg
 
OWASP Top 10 - DrupalCon Amsterdam 2019
OWASP Top 10 - DrupalCon Amsterdam 2019OWASP Top 10 - DrupalCon Amsterdam 2019
OWASP Top 10 - DrupalCon Amsterdam 2019Ayesh Karunaratne
 
Dynomite at Erlang Factory
Dynomite at Erlang FactoryDynomite at Erlang Factory
Dynomite at Erlang Factorymoonpolysoft
 
Hacking Parse.y with ujihisa
Hacking Parse.y with ujihisaHacking Parse.y with ujihisa
Hacking Parse.y with ujihisaujihisa
 
Nodejs性能分析优化和分布式设计探讨
Nodejs性能分析优化和分布式设计探讨Nodejs性能分析优化和分布式设计探讨
Nodejs性能分析优化和分布式设计探讨flyinweb
 

Semelhante a Benchmarking Perl performance and memory usage (20)

Ruby 1.9
Ruby 1.9Ruby 1.9
Ruby 1.9
 
Memory Manglement in Raku
Memory Manglement in RakuMemory Manglement in Raku
Memory Manglement in Raku
 
Ruby on Rails Intro
Ruby on Rails IntroRuby on Rails Intro
Ruby on Rails Intro
 
Being functional in PHP (PHPDay Italy 2016)
Being functional in PHP (PHPDay Italy 2016)Being functional in PHP (PHPDay Italy 2016)
Being functional in PHP (PHPDay Italy 2016)
 
Bioinformatica p4-io
Bioinformatica p4-ioBioinformatica p4-io
Bioinformatica p4-io
 
Rooted 2010 ppp
Rooted 2010 pppRooted 2010 ppp
Rooted 2010 ppp
 
Sge
SgeSge
Sge
 
Tt subtemplates-caching
Tt subtemplates-cachingTt subtemplates-caching
Tt subtemplates-caching
 
Fpga 06-data-types-system-tasks-compiler-directives
Fpga 06-data-types-system-tasks-compiler-directivesFpga 06-data-types-system-tasks-compiler-directives
Fpga 06-data-types-system-tasks-compiler-directives
 
Plsql
PlsqlPlsql
Plsql
 
Tips on how to improve the performance of your custom modules for high volume...
Tips on how to improve the performance of your custom modules for high volume...Tips on how to improve the performance of your custom modules for high volume...
Tips on how to improve the performance of your custom modules for high volume...
 
String Comparison Surprises: Did Postgres lose my data?
String Comparison Surprises: Did Postgres lose my data?String Comparison Surprises: Did Postgres lose my data?
String Comparison Surprises: Did Postgres lose my data?
 
Joker 2015 - Валеев Тагир - Что же мы измеряем?
Joker 2015 - Валеев Тагир - Что же мы измеряем?Joker 2015 - Валеев Тагир - Что же мы измеряем?
Joker 2015 - Валеев Тагир - Что же мы измеряем?
 
Степан Кольцов — Rust — лучше, чем C++
Степан Кольцов — Rust — лучше, чем C++Степан Кольцов — Rust — лучше, чем C++
Степан Кольцов — Rust — лучше, чем C++
 
Easing the Complex with SPBench framework
Easing the Complex with SPBench frameworkEasing the Complex with SPBench framework
Easing the Complex with SPBench framework
 
OWASP Top 10 - DrupalCon Amsterdam 2019
OWASP Top 10 - DrupalCon Amsterdam 2019OWASP Top 10 - DrupalCon Amsterdam 2019
OWASP Top 10 - DrupalCon Amsterdam 2019
 
Dynomite at Erlang Factory
Dynomite at Erlang FactoryDynomite at Erlang Factory
Dynomite at Erlang Factory
 
Hacking Parse.y with ujihisa
Hacking Parse.y with ujihisaHacking Parse.y with ujihisa
Hacking Parse.y with ujihisa
 
Groovy
GroovyGroovy
Groovy
 
Nodejs性能分析优化和分布式设计探讨
Nodejs性能分析优化和分布式设计探讨Nodejs性能分析优化和分布式设计探讨
Nodejs性能分析优化和分布式设计探讨
 

Mais de brian d foy

Conferences for Beginners presentation
Conferences for Beginners presentationConferences for Beginners presentation
Conferences for Beginners presentationbrian d foy
 
20 years in Perl
20 years in Perl20 years in Perl
20 years in Perlbrian d foy
 
PrettyDump Perl 6 (London.pm)
PrettyDump Perl 6 (London.pm)PrettyDump Perl 6 (London.pm)
PrettyDump Perl 6 (London.pm)brian d foy
 
Dumping Perl 6 (French Perl Workshop)
Dumping Perl 6 (French Perl Workshop)Dumping Perl 6 (French Perl Workshop)
Dumping Perl 6 (French Perl Workshop)brian d foy
 
Perl v5.26 Features (AmsterdamX.pm)
Perl v5.26 Features (AmsterdamX.pm)Perl v5.26 Features (AmsterdamX.pm)
Perl v5.26 Features (AmsterdamX.pm)brian d foy
 
Dumping Perl 6 (AmsterdamX.pm)
Dumping Perl 6 (AmsterdamX.pm)Dumping Perl 6 (AmsterdamX.pm)
Dumping Perl 6 (AmsterdamX.pm)brian d foy
 
6 more things about Perl 6
6 more things about Perl 66 more things about Perl 6
6 more things about Perl 6brian d foy
 
6 things about perl 6
6 things about perl 66 things about perl 6
6 things about perl 6brian d foy
 
Perl 5.28 new features
Perl 5.28 new featuresPerl 5.28 new features
Perl 5.28 new featuresbrian d foy
 
The Surprisingly Tense History of the Schwartzian Transform
The Surprisingly Tense History of the Schwartzian TransformThe Surprisingly Tense History of the Schwartzian Transform
The Surprisingly Tense History of the Schwartzian Transformbrian d foy
 
Perl Power Tools - Saint Perl 6
Perl Power Tools - Saint Perl 6Perl Power Tools - Saint Perl 6
Perl Power Tools - Saint Perl 6brian d foy
 
Perl Bag of Tricks - Baltimore Perl mongers
Perl Bag of Tricks  -  Baltimore Perl mongersPerl Bag of Tricks  -  Baltimore Perl mongers
Perl Bag of Tricks - Baltimore Perl mongersbrian d foy
 
The Whitespace in the Perl Community
The Whitespace in the Perl CommunityThe Whitespace in the Perl Community
The Whitespace in the Perl Communitybrian d foy
 
CPAN Workshop, Chicago 2014
CPAN Workshop, Chicago 2014CPAN Workshop, Chicago 2014
CPAN Workshop, Chicago 2014brian d foy
 
Parsing JSON with a single regex
Parsing JSON with a single regexParsing JSON with a single regex
Parsing JSON with a single regexbrian d foy
 
Reverse Installing CPAN
Reverse Installing CPANReverse Installing CPAN
Reverse Installing CPANbrian d foy
 
Advanced modulinos
Advanced modulinosAdvanced modulinos
Advanced modulinosbrian d foy
 
Advanced modulinos trial
Advanced modulinos trialAdvanced modulinos trial
Advanced modulinos trialbrian d foy
 

Mais de brian d foy (20)

Conferences for Beginners presentation
Conferences for Beginners presentationConferences for Beginners presentation
Conferences for Beginners presentation
 
20 years in Perl
20 years in Perl20 years in Perl
20 years in Perl
 
PrettyDump Perl 6 (London.pm)
PrettyDump Perl 6 (London.pm)PrettyDump Perl 6 (London.pm)
PrettyDump Perl 6 (London.pm)
 
Dumping Perl 6 (French Perl Workshop)
Dumping Perl 6 (French Perl Workshop)Dumping Perl 6 (French Perl Workshop)
Dumping Perl 6 (French Perl Workshop)
 
Perl v5.26 Features (AmsterdamX.pm)
Perl v5.26 Features (AmsterdamX.pm)Perl v5.26 Features (AmsterdamX.pm)
Perl v5.26 Features (AmsterdamX.pm)
 
Dumping Perl 6 (AmsterdamX.pm)
Dumping Perl 6 (AmsterdamX.pm)Dumping Perl 6 (AmsterdamX.pm)
Dumping Perl 6 (AmsterdamX.pm)
 
6 more things about Perl 6
6 more things about Perl 66 more things about Perl 6
6 more things about Perl 6
 
6 things about perl 6
6 things about perl 66 things about perl 6
6 things about perl 6
 
Perl 5.28 new features
Perl 5.28 new featuresPerl 5.28 new features
Perl 5.28 new features
 
The Surprisingly Tense History of the Schwartzian Transform
The Surprisingly Tense History of the Schwartzian TransformThe Surprisingly Tense History of the Schwartzian Transform
The Surprisingly Tense History of the Schwartzian Transform
 
Perl Power Tools - Saint Perl 6
Perl Power Tools - Saint Perl 6Perl Power Tools - Saint Perl 6
Perl Power Tools - Saint Perl 6
 
Perl Bag of Tricks - Baltimore Perl mongers
Perl Bag of Tricks  -  Baltimore Perl mongersPerl Bag of Tricks  -  Baltimore Perl mongers
Perl Bag of Tricks - Baltimore Perl mongers
 
The Whitespace in the Perl Community
The Whitespace in the Perl CommunityThe Whitespace in the Perl Community
The Whitespace in the Perl Community
 
CPAN Workshop, Chicago 2014
CPAN Workshop, Chicago 2014CPAN Workshop, Chicago 2014
CPAN Workshop, Chicago 2014
 
Parsing JSON with a single regex
Parsing JSON with a single regexParsing JSON with a single regex
Parsing JSON with a single regex
 
Reverse Installing CPAN
Reverse Installing CPANReverse Installing CPAN
Reverse Installing CPAN
 
Advanced modulinos
Advanced modulinosAdvanced modulinos
Advanced modulinos
 
Advanced modulinos trial
Advanced modulinos trialAdvanced modulinos trial
Advanced modulinos trial
 
Bag of tricks
Bag of tricksBag of tricks
Bag of tricks
 
I ❤ CPAN
I ❤ CPANI ❤ CPAN
I ❤ CPAN
 

Último

The Economic History of the U.S. Lecture 22.pdf
The Economic History of the U.S. Lecture 22.pdfThe Economic History of the U.S. Lecture 22.pdf
The Economic History of the U.S. Lecture 22.pdfGale Pooley
 
VIP Call Girls Service Dilsukhnagar Hyderabad Call +91-8250192130
VIP Call Girls Service Dilsukhnagar Hyderabad Call +91-8250192130VIP Call Girls Service Dilsukhnagar Hyderabad Call +91-8250192130
VIP Call Girls Service Dilsukhnagar Hyderabad Call +91-8250192130Suhani Kapoor
 
High Class Call Girls Nashik Maya 7001305949 Independent Escort Service Nashik
High Class Call Girls Nashik Maya 7001305949 Independent Escort Service NashikHigh Class Call Girls Nashik Maya 7001305949 Independent Escort Service Nashik
High Class Call Girls Nashik Maya 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Call Girls Koregaon Park Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Koregaon Park Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Koregaon Park Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Koregaon Park Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
 
Pooja 9892124323 : Call Girl in Juhu Escorts Service Free Home Delivery
Pooja 9892124323 : Call Girl in Juhu Escorts Service Free Home DeliveryPooja 9892124323 : Call Girl in Juhu Escorts Service Free Home Delivery
Pooja 9892124323 : Call Girl in Juhu Escorts Service Free Home DeliveryPooja Nehwal
 
Instant Issue Debit Cards - High School Spirit
Instant Issue Debit Cards - High School SpiritInstant Issue Debit Cards - High School Spirit
Instant Issue Debit Cards - High School Spiritegoetzinger
 
Dividend Policy and Dividend Decision Theories.pptx
Dividend Policy and Dividend Decision Theories.pptxDividend Policy and Dividend Decision Theories.pptx
Dividend Policy and Dividend Decision Theories.pptxanshikagoel52
 
Log your LOA pain with Pension Lab's brilliant campaign
Log your LOA pain with Pension Lab's brilliant campaignLog your LOA pain with Pension Lab's brilliant campaign
Log your LOA pain with Pension Lab's brilliant campaignHenry Tapper
 
Dharavi Russian callg Girls, { 09892124323 } || Call Girl In Mumbai ...
Dharavi Russian callg Girls, { 09892124323 } || Call Girl In Mumbai ...Dharavi Russian callg Girls, { 09892124323 } || Call Girl In Mumbai ...
Dharavi Russian callg Girls, { 09892124323 } || Call Girl In Mumbai ...Pooja Nehwal
 
Vip Call US 📞 7738631006 ✅Call Girls In Sakinaka ( Mumbai )
Vip Call US 📞 7738631006 ✅Call Girls In Sakinaka ( Mumbai )Vip Call US 📞 7738631006 ✅Call Girls In Sakinaka ( Mumbai )
Vip Call US 📞 7738631006 ✅Call Girls In Sakinaka ( Mumbai )Pooja Nehwal
 
05_Annelore Lenoir_Docbyte_MeetupDora&Cybersecurity.pptx
05_Annelore Lenoir_Docbyte_MeetupDora&Cybersecurity.pptx05_Annelore Lenoir_Docbyte_MeetupDora&Cybersecurity.pptx
05_Annelore Lenoir_Docbyte_MeetupDora&Cybersecurity.pptxFinTech Belgium
 
00_Main ppt_MeetupDORA&CyberSecurity.pptx
00_Main ppt_MeetupDORA&CyberSecurity.pptx00_Main ppt_MeetupDORA&CyberSecurity.pptx
00_Main ppt_MeetupDORA&CyberSecurity.pptxFinTech Belgium
 
Solution Manual for Principles of Corporate Finance 14th Edition by Richard B...
Solution Manual for Principles of Corporate Finance 14th Edition by Richard B...Solution Manual for Principles of Corporate Finance 14th Edition by Richard B...
Solution Manual for Principles of Corporate Finance 14th Edition by Richard B...ssifa0344
 
VIP Kolkata Call Girl Serampore 👉 8250192130 Available With Room
VIP Kolkata Call Girl Serampore 👉 8250192130  Available With RoomVIP Kolkata Call Girl Serampore 👉 8250192130  Available With Room
VIP Kolkata Call Girl Serampore 👉 8250192130 Available With Roomdivyansh0kumar0
 
The Economic History of the U.S. Lecture 30.pdf
The Economic History of the U.S. Lecture 30.pdfThe Economic History of the U.S. Lecture 30.pdf
The Economic History of the U.S. Lecture 30.pdfGale Pooley
 
Malad Call Girl in Services 9892124323 | ₹,4500 With Room Free Delivery
Malad Call Girl in Services  9892124323 | ₹,4500 With Room Free DeliveryMalad Call Girl in Services  9892124323 | ₹,4500 With Room Free Delivery
Malad Call Girl in Services 9892124323 | ₹,4500 With Room Free DeliveryPooja Nehwal
 
VIP Kolkata Call Girl Jodhpur Park 👉 8250192130 Available With Room
VIP Kolkata Call Girl Jodhpur Park 👉 8250192130  Available With RoomVIP Kolkata Call Girl Jodhpur Park 👉 8250192130  Available With Room
VIP Kolkata Call Girl Jodhpur Park 👉 8250192130 Available With Roomdivyansh0kumar0
 
VVIP Pune Call Girls Katraj (7001035870) Pune Escorts Nearby with Complete Sa...
VVIP Pune Call Girls Katraj (7001035870) Pune Escorts Nearby with Complete Sa...VVIP Pune Call Girls Katraj (7001035870) Pune Escorts Nearby with Complete Sa...
VVIP Pune Call Girls Katraj (7001035870) Pune Escorts Nearby with Complete Sa...Call Girls in Nagpur High Profile
 
Independent Call Girl Number in Kurla Mumbai📲 Pooja Nehwal 9892124323 💞 Full ...
Independent Call Girl Number in Kurla Mumbai📲 Pooja Nehwal 9892124323 💞 Full ...Independent Call Girl Number in Kurla Mumbai📲 Pooja Nehwal 9892124323 💞 Full ...
Independent Call Girl Number in Kurla Mumbai📲 Pooja Nehwal 9892124323 💞 Full ...Pooja Nehwal
 

Último (20)

The Economic History of the U.S. Lecture 22.pdf
The Economic History of the U.S. Lecture 22.pdfThe Economic History of the U.S. Lecture 22.pdf
The Economic History of the U.S. Lecture 22.pdf
 
VIP Call Girls Service Dilsukhnagar Hyderabad Call +91-8250192130
VIP Call Girls Service Dilsukhnagar Hyderabad Call +91-8250192130VIP Call Girls Service Dilsukhnagar Hyderabad Call +91-8250192130
VIP Call Girls Service Dilsukhnagar Hyderabad Call +91-8250192130
 
High Class Call Girls Nashik Maya 7001305949 Independent Escort Service Nashik
High Class Call Girls Nashik Maya 7001305949 Independent Escort Service NashikHigh Class Call Girls Nashik Maya 7001305949 Independent Escort Service Nashik
High Class Call Girls Nashik Maya 7001305949 Independent Escort Service Nashik
 
Call Girls Koregaon Park Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Koregaon Park Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Koregaon Park Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Koregaon Park Call Me 7737669865 Budget Friendly No Advance Booking
 
Pooja 9892124323 : Call Girl in Juhu Escorts Service Free Home Delivery
Pooja 9892124323 : Call Girl in Juhu Escorts Service Free Home DeliveryPooja 9892124323 : Call Girl in Juhu Escorts Service Free Home Delivery
Pooja 9892124323 : Call Girl in Juhu Escorts Service Free Home Delivery
 
Instant Issue Debit Cards - High School Spirit
Instant Issue Debit Cards - High School SpiritInstant Issue Debit Cards - High School Spirit
Instant Issue Debit Cards - High School Spirit
 
Dividend Policy and Dividend Decision Theories.pptx
Dividend Policy and Dividend Decision Theories.pptxDividend Policy and Dividend Decision Theories.pptx
Dividend Policy and Dividend Decision Theories.pptx
 
Log your LOA pain with Pension Lab's brilliant campaign
Log your LOA pain with Pension Lab's brilliant campaignLog your LOA pain with Pension Lab's brilliant campaign
Log your LOA pain with Pension Lab's brilliant campaign
 
Dharavi Russian callg Girls, { 09892124323 } || Call Girl In Mumbai ...
Dharavi Russian callg Girls, { 09892124323 } || Call Girl In Mumbai ...Dharavi Russian callg Girls, { 09892124323 } || Call Girl In Mumbai ...
Dharavi Russian callg Girls, { 09892124323 } || Call Girl In Mumbai ...
 
Vip Call US 📞 7738631006 ✅Call Girls In Sakinaka ( Mumbai )
Vip Call US 📞 7738631006 ✅Call Girls In Sakinaka ( Mumbai )Vip Call US 📞 7738631006 ✅Call Girls In Sakinaka ( Mumbai )
Vip Call US 📞 7738631006 ✅Call Girls In Sakinaka ( Mumbai )
 
05_Annelore Lenoir_Docbyte_MeetupDora&Cybersecurity.pptx
05_Annelore Lenoir_Docbyte_MeetupDora&Cybersecurity.pptx05_Annelore Lenoir_Docbyte_MeetupDora&Cybersecurity.pptx
05_Annelore Lenoir_Docbyte_MeetupDora&Cybersecurity.pptx
 
00_Main ppt_MeetupDORA&CyberSecurity.pptx
00_Main ppt_MeetupDORA&CyberSecurity.pptx00_Main ppt_MeetupDORA&CyberSecurity.pptx
00_Main ppt_MeetupDORA&CyberSecurity.pptx
 
Solution Manual for Principles of Corporate Finance 14th Edition by Richard B...
Solution Manual for Principles of Corporate Finance 14th Edition by Richard B...Solution Manual for Principles of Corporate Finance 14th Edition by Richard B...
Solution Manual for Principles of Corporate Finance 14th Edition by Richard B...
 
Commercial Bank Economic Capsule - April 2024
Commercial Bank Economic Capsule - April 2024Commercial Bank Economic Capsule - April 2024
Commercial Bank Economic Capsule - April 2024
 
VIP Kolkata Call Girl Serampore 👉 8250192130 Available With Room
VIP Kolkata Call Girl Serampore 👉 8250192130  Available With RoomVIP Kolkata Call Girl Serampore 👉 8250192130  Available With Room
VIP Kolkata Call Girl Serampore 👉 8250192130 Available With Room
 
The Economic History of the U.S. Lecture 30.pdf
The Economic History of the U.S. Lecture 30.pdfThe Economic History of the U.S. Lecture 30.pdf
The Economic History of the U.S. Lecture 30.pdf
 
Malad Call Girl in Services 9892124323 | ₹,4500 With Room Free Delivery
Malad Call Girl in Services  9892124323 | ₹,4500 With Room Free DeliveryMalad Call Girl in Services  9892124323 | ₹,4500 With Room Free Delivery
Malad Call Girl in Services 9892124323 | ₹,4500 With Room Free Delivery
 
VIP Kolkata Call Girl Jodhpur Park 👉 8250192130 Available With Room
VIP Kolkata Call Girl Jodhpur Park 👉 8250192130  Available With RoomVIP Kolkata Call Girl Jodhpur Park 👉 8250192130  Available With Room
VIP Kolkata Call Girl Jodhpur Park 👉 8250192130 Available With Room
 
VVIP Pune Call Girls Katraj (7001035870) Pune Escorts Nearby with Complete Sa...
VVIP Pune Call Girls Katraj (7001035870) Pune Escorts Nearby with Complete Sa...VVIP Pune Call Girls Katraj (7001035870) Pune Escorts Nearby with Complete Sa...
VVIP Pune Call Girls Katraj (7001035870) Pune Escorts Nearby with Complete Sa...
 
Independent Call Girl Number in Kurla Mumbai📲 Pooja Nehwal 9892124323 💞 Full ...
Independent Call Girl Number in Kurla Mumbai📲 Pooja Nehwal 9892124323 💞 Full ...Independent Call Girl Number in Kurla Mumbai📲 Pooja Nehwal 9892124323 💞 Full ...
Independent Call Girl Number in Kurla Mumbai📲 Pooja Nehwal 9892124323 💞 Full ...
 

Benchmarking Perl performance and memory usage

  • 1. Benchmarking Perl brian d foy Stonehenge Consulting Ser vices March 14, 2006 Chicago UniForum
  • 2. Know where you are “A benchmark is a point of reference for a measurement. The term originates from the chiseled horizontal marks that sur veyors made into which an angle-iron could be placed to bracket (bench) a leveling rod, thus ensuring that the leveling rod can be repositioned in the exact same place in the future.” http:/ /en.wikipedia.org/wiki/Benchmark
  • 5. Nobody is ferpect It’s only relative It has to be the same answer next time If something changes, the reference is meaningless
  • 6. Computer Benchmarks Standard Performance Evaluation Corporation (SPEC) CPU (2000, 95, 92) Graphics Web ser vers http://www.spec.org/
  • 7. All Things Being Equal... There are lies, damned lies, and benchmarks Everyone has an agenda You don’t run testbeds as production Skepticism wins the day
  • 8. Language Shootout Benchmarking programming languages? How can we benchmark a programming language? We can't - we benchmark programming language implementations. How can we benchmark language implementations? We can't - we measure particular programs. http:/ /shootout.alioth.debian.org/
  • 9. Performance A major factor in determining the overall productivity of a system, performance is primarily tied to availability, throughput and response time. http://www.comptia.org/sections/ssg/glossary.aspx
  • 10. Performance (2) A performance comprises an event in which generally one group of people behave in a particular way for another group of people http://en.wikipedia.org/wiki/Performance
  • 11. Performance (3) “Your investment's activity over time. Past performance does not guarantee future results.” My accountant
  • 12. How many metrics can you name?
  • 13. Availability Disk Use Concurrent Users CPU Time Completion Time Memory Use Uptime Bandwidth Use Net work Lag Responsiveness Binary Size
  • 14. Programmer Time
  • 17. You haven’t said “Perl” Perl is just a programming language It’s a High Level Language Measure Perl the same as other things Measure Perl against itself Compare the results
  • 19. It’s not just speed
  • 20. Memory Use use Devel::Size qw(size total_size); my $size = size(quot;A stringquot;); my @foo = (1, 2, 3, 4, 5); my $other_size = size(@foo); my $foo = { a => [1, 2, 3], b => {a => [1, 3, 4]} }; my $total_size = total_size($foo);
  • 21. Memory Use (2) use Devel::Peek; Dump( $a ); Dump( $a, 5 ); DumpArray( 5, $a, $b, ... ); mstat quot;Point 5quot;; Need PERL_DEBUG_MSTATS
  • 22. Database query time $ DBI_PROFILE=2 db_script DBI::Profile: 0.001015s (5 calls) db_script @ YYYY-MM-DD HH:MM:SS '' => 0.000024s / 2 = 0.000012s avg (first 0.000015s, min 0.000009s, max 0.000015s) 'SELECT mode,size,name FROM table' => 0.000991s / 3 = 0.000330s avg (first 0.000678s, min 0.000009s, max 0.000678s)
  • 24. ...and it sux... Sux : Sucks :: Kwalitee : Quality
  • 25. Common misuse use Benchmark 'cmpthese'; my @long = ('a' .. 'z', ''); my $iter = shift || -1; cmpthese( $iter,{ long_block_ne => q{grep {$_ ne ''} @long}, long_block_len => q{grep {length} @long}, long_bare_ne => q{grep $_ ne '', @long}, long_bare_len => q{grep length, @long}, } ); http://www.perlmonks.org/index.pl?node_id=536503
  • 26. What’s wrong with this picture? Rate bare_ne block_len block_ne bare_len long_bare_ne 3635361/s -- -6% -6% -8% long_block_len 3869054/s 6% -- -0% -2% long_block_ne 3872708/s 7% 0% -- -2% long_bare_len 3963159/s 9% 2% 2% --
  • 27. Mac OS X.4.5 15” G4 Powerbook perl5.8.4 Rate bare_len bare_ne block_ne block_len long_bare_len 2805822/s -- -0% -1% -3% long_bare_ne 2805822/s 0% -- -1% -3% long_block_ne 2840569/s 1% 1% -- -2% long_block_len 2885232/s 3% 3% 2% --
  • 28. This is perl, v5.8.4 built for darwin-2level Summary of my perl5 (revision 5 version 8 subversion 4) configuration: Platform: osname=darwin, osvers=7.3.1, archname=darwin-2level uname='darwin albook.local 7.3.1 darwin kernel version 7.3.1: mon mar 22 21:48:41 pst 2004; root:xnuxnu-517.4.12.obj~2release_ppc power macintosh powerpc ' config_args='' hint=recommended, useposix=true, d_sigaction=define usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-pipe -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict- aliasing', optimize='-Os', cppflags='-no-cpp-precomp -pipe -fno-common -DPERL_DARWIN -no-cpp-precomp -fno- strict-aliasing' ccversion='', gccversion='3.3 20030304 (Apple Computer, Inc. build 1640)', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags ='' libpth=/usr/lib libs=-ldbm -ldl -lm -lc perllibs=-ldl -lm -lc libc=/usr/lib/libc.dylib, so=dylib, useshrplib=false, libperl=libperl.a gnulibc_version='' Dynamic Linking: dlsrc=dl_dyld.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' ' cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup'
  • 30. Do something useful use Benchmark 'cmpthese'; our @long = ('a' .. 'z', ''); my $iter = shift || -1; cmpthese( $iter,{ long_block_ne => q{my @array = grep {$_ ne ''} @long}, long_block_len => q{my @array = grep {length} @long}, long_bare_ne => q{my @array = grep $_ ne '', @long}, long_bare_len => q{my @array = grep length, @long}, } );
  • 31. These numbers make sense Rate block_ne block_len bare_ne bare_len long_block_ne 31210/s -- -3% -3% -5% long_block_len 32119/s 3% -- -0% -2% long_bare_ne 32237/s 3% 0% -- -2% long_bare_len 32755/s 5% 2% 2% --
  • 32. Don’t Trust! Verify! use Benchmark 'cmpthese'; our @long = ('a' .. 'z', 0 .. 10_000, ''); my $iter = shift || -1; cmpthese( $iter,{ long_block_ne => q{my @array = grep {$_ ne ''} @long}, long_block_len => q{my @array = grep {length} @long}, long_bare_ne => q{my @array = grep $_ ne '', @long}, long_bare_len => q{my @array = grep length, @long}, } );
  • 33. It takes longer to do more Rate bare_ne block_ne block_len bare_len long_bare_ne 59.8/s -- -1% -2% -3% long_block_ne 60.4/s 1% -- -1% -3% long_block_len 60.9/s 2% 1% -- -2% long_bare_len 61.9/s 4% 3% 2% --
  • 34. Theory of Measurement Obser vation changes the universe Nothing is objective Tools have inherent uncertainities
  • 35. Precision is repeatability
  • 36. Accuracy is getting the right answer
  • 39. Benchmark.pm’s benchmark Uses a null loop as a control sub { } It’s just a timer Subtracts the null loop time Introduces an error of about 7%
  • 40. $ time perl script.pl real 0m0.293s user 0m0.130s sys 0m0.036s http://ppt.perl.org/
  • 41. The map is not the terrain my @selected = grep { ... } @array; () = grep { ... } @array; my @selected = @array; my @selected = ( ... ); my @selected ;
  • 42. $ perl -MO=Concise -e 'grep { lc } @array' a <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 2 -e:1) v ->3 7 <|> grepwhile(other->8)[t4] vK/1 ->a 6 <@> grepstart K*/2 ->7 3 <0> pushmark s ->4 - <1> null lK/1 ->4 - <1> null sK/1 ->7 - <@> scope sK ->7 - <0> ex-nextstate v ->8 9 <1> lc[t2] sK/1 ->- - <1> ex-rv2sv sK/1 ->9 8 <$> gvsv(*_) s ->9 5 <1> rv2av[t3] lKM/1 ->6 4 <$> gv(*array) s ->5
  • 43. $ perl -MO=Concise -e '() = grep { lc } @array' d <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 2 -e:1) v ->3 c <2> aassign[t5] vKS/COMMON ->d - <1> ex-list lK ->b 3 <0> pushmark s ->4 8 <|> grepwhile(other->9)[t4] lK/1 ->b 7 <@> grepstart lK*/2 ->8 4 <0> pushmark s ->5 - <1> null lK/1 ->5 - <1> null sK/1 ->8 - <@> scope sK ->8 - <0> ex-nextstate v ->9 a <1> lc[t2] sK/1 ->- - <1> ex-rv2sv sK/1 ->a 9 <$> gvsv(*_) s ->a 6 <1> rv2av[t3] lKM/1 ->7 5 <$> gv(*array) s ->6 - <1> ex-list lK ->c b <0> pushmark s ->c - <0> stub lPRM* ->-
  • 44. $ perl -MO=Concise -e 'my @selected = grep { lc } @array' e <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 2 -e:1) v ->3 d <2> aassign[t6] vKS ->e - <1> ex-list lK ->b 3 <0> pushmark s ->4 8 <|> grepwhile(other->9)[t5] lK/1 ->b 7 <@> grepstart lK*/2 ->8 4 <0> pushmark s ->5 - <1> null lK/1 ->5 - <1> null sK/1 ->8 - <@> scope sK ->8 - <0> ex-nextstate v ->9 a <1> lc[t3] sK/1 ->- - <1> ex-rv2sv sK/1 ->a 9 <$> gvsv(*_) s ->a 6 <1> rv2av[t4] lKM/1 ->7 5 <$> gv(*array) s ->6 - <1> ex-list lK ->d b <0> pushmark s ->c c <0> padav[@selected:2,3] lRM*/LVINTRO ->d
  • 45. “Premature optimization is the root of all evil” Tony Hoare
  • 46. What do I benchmark?
  • 47. Find the bad parts Profile the application first Find out who’s taking all the time/ memory/net work Compare situations Fix that first
  • 50. Summary Decide what is important to you Realize you have bias Report the situation Don’t turn off your brain Make predictions that you can verify
  • 51. Further Reading “Benchmarking”, The Perl Journal #11, http://www.pair.com/~comdog/Articles/benchmark.1_4.txt “Wasting Time Thinking About Wasted Time”, http://www.perlmonks.org/?node_id=393128 “Profiling in Perl”, http://www.ddj.com/documents/s=1498/ddj0104pl/