title: profiling simple python script
body: <p>i was experimenting with <code>cProfile</code> for profiling python applications.so i wrote a simple script and below is the results that i have.</p>
  
  <pre><code>def foo():
    for i in range(100000):
      print i
  
  def bar():
    for i in range(100):
      print "bar"*i
  
  foo()
  bar()
  </code></pre>
  
  <p>When i run the above script as <code>python -m profile script.py</code> i get this output:</p>
  
  <pre><code>         7 function calls in 0.136 seconds
  
     Ordered by: standard name
  
     ncalls  tottime  percall  cumtime  percall filename:lineno(function)
          2    0.000    0.000    0.000    0.000 :0(range)
          1    0.000    0.000    0.000    0.000 :0(setprofile)
          1    0.000    0.000    0.136    0.136 lip.py:1(&lt;module&gt;)
          1    0.136    0.136    0.136    0.136 lip.py:1(foo)
          1    0.000    0.000    0.000    0.000 lip.py:5(bar)
          1    0.000    0.000    0.136    0.136 profile:0(&lt;code object &lt;module&gt; at 0x7fae5a978a30, file "lip.py", line 1&gt;)
          0    0.000             0.000          profile:0(profiler)
  </code></pre>
  
  <p>but from the ouptut is seems only method <code>foo</code> consumed <strong>0.136 s</strong> to excute while it was <strong>0.00 s</strong> for method <code>bar</code>. why is that?</p>