PyCon mini JP 2011 Lightning Talk




Benchmarker
a good friend for performance



  makoto kuwata
  http://www.kuwata-lab.com/
Profile
 @makotokuwata

 http://www.kwuata-lab.com/
              Perl is the
 Ruby/PHP/Python programmer

          CHAMPION!
 Creator of Erubis (*)

 Python4PHPer


                (*) default template engine on Rails 3
Question
Which is faster?
  	       	 
 	  	  	  	  	  	  	  	  	  	 

  	 
 	  	                  	  	        	     	    	    	 

  	 
 	  	                 	     	     	     	 
                           https://gist.github.com/800384
Benchmark
                                   '+' op is the fastest
                                   for short strings


plus op             0.624sec


 format                            0.887sec


   join                   0.709sec

          0   0.2   0.4      0.6       0.8      1

                           second per million
Which is faster?
    	       	 
   	  	 
      	  	  	 
 	 	  	  	 

    	     	      	 
   	  	 
      	  	  	 
 	 	  	  	  	  	 
                      https://gist.github.com/801429
Benchmark
                                              Not Same!



'+=' op                         0.431sec




'=' & '+'                          0.439sec


            0   0.1   0.2    0.3       0.4       0.5

                            second per million
Which is faster?
    	       	 
   	  	 
      	  	  	 
 	 	  	  	  	  	 

    	     	      	 
   	  	 
      	  	  	 
 	 	  	  	  	  	  	  	 
                          https://gist.github.com/801429
Benchmark

   '+=' op        0.545sec




'=' and '+'       Too Slow! Unmeasurable!


              0       0.4    0.8    1.2     1.6         2

                                   second per million
Why?
[OT] Python v.s. Perl
[OT] Python v.s. Perl
     	             	 
 	 	 	 	 	 	 	 	 	 	 	 	  	  	 	  	  	 	  	  	 	  	  	 
             	  	  	 	 	 	  	 	 	 	  	 	 	 	  	 	 	 	 

     	        	 
                     Perl is
 	 	 	 	  	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 
 	 	 	 	 	  	  	  	  	  	  	  	  	  	  	 

                   AWESOME!
About Benchmarker
Benchmarker
 Benchmarking utility for Python
 A good friend for performance
 http://pypi.python.org/pypi/Benchmarker/
Example Code
Output
Remove same fot-stmt
Repeat all benchmarks
     	 
          	                                                 	    	 
 	 	  	            	  	 
 	 	       	  	  	 
 	 	 	 	        	                  	 
 	 	 	 	 	 	 
                                                Remove min & max results
Command-line Options
thank you

Benchmarker - A Good Friend for Performance