title: How to interpret the results of profiling?
body: <p>I am not a computer scientist and I have been having a hard time trying to make my agent-based model reasonably fast (<a href="https://stackoverflow.com/questions/38212265/implementing-pool-on-a-for-loop-with-a-lot-of-inputs">Implementing Pool on a for loop with a lot of inputs</a>, <a href="https://stackoverflow.com/questions/38165552/multiprocessing-pool-example-parallel-is-slower-than-sequential-trying-to-und">Multiprocessing pool example (parallel) is slower than sequential. Trying to understand pool in python</a>, <a href="https://stackoverflow.com/questions/38204284/returning-lists-of-instances-makes-no-difference-and-what-about-performance">Returning lists of instances makes no difference? And what about performance?</a>)</p>
  
  <p>Everybody keeps telling me to profile. I gave it another shot, but I have no idea how to interpret the results (using <code>timeit</code> I know which function is slower, but I could not use <code>Pool</code> or <code>@jit</code>). </p>
  
  <p>So given the results below, how should I proceed?
  Thanks a bunch.</p>
  
  <pre><code>98008290 function calls (96393650 primitive calls) in 568.193 seconds
  Ordered by: standard name
  
  ncalls  tottime  percall  cumtime  percall filename:lineno(function)
      1    0.000    0.000    0.000    0.000 &lt;decorator-gen-0&gt;:1(&lt;module&gt;)
      1    0.000    0.000    0.000    0.000 &lt;decorator-gen-10&gt;:1(&lt;module&gt;)
      1    0.000    0.000    0.000    0.000 &lt;decorator-gen-11&gt;:1(&lt;module&gt;)
      1    0.000    0.000    0.000    0.000 &lt;decorator-gen-1&gt;:1(&lt;module&gt;)
      6    0.000    0.000    0.006    0.001 &lt;decorator-gen-1&gt;:1(non_reentrant)
      1    0.000    0.000    0.000    0.000 &lt;decorator-gen-2&gt;:1(&lt;module&gt;)
      1    0.000    0.000    0.000    0.000 &lt;decorator-gen-3&gt;:1(&lt;module&gt;)
      1    0.000    0.000    0.000    0.000 &lt;decorator-gen-4&gt;:1(&lt;module&gt;)
      1    0.000    0.000    0.000    0.000 &lt;decorator-gen-5&gt;:1(&lt;module&gt;)
      1    0.000    0.000    0.000    0.000 &lt;decorator-gen-6&gt;:1(&lt;module&gt;)
      1    0.000    0.000    0.000    0.000 &lt;decorator-gen-7&gt;:1(&lt;module&gt;)
      1    0.000    0.000    0.000    0.000 &lt;decorator-gen-8&gt;:1(&lt;module&gt;)
      3    0.000    0.000    0.002    0.001 &lt;decorator-gen-8&gt;:1(_held_figure)
      1    0.000    0.000    0.000    0.000 &lt;decorator-gen-9&gt;:1(&lt;module&gt;)
   1416    0.003    0.000    0.003    0.000 &lt;frozen importlib._bootstrap&gt;:1000(__init__)
      2    0.000    0.000    0.000    0.000 &lt;frozen importlib._bootstrap&gt;:1003(module_repr)
   1245    0.034    0.000    0.166    0.000 &lt;frozen importlib._bootstrap&gt;:1019(init_module_attrs)
   1245    0.011    0.000    0.209    0.000 &lt;frozen importlib._bootstrap&gt;:1099(create)
   1245/32    0.008    0.000   23.613    0.738 &lt;frozen importlib._bootstrap&gt;:1122(_exec)
   169/105    0.003    0.000    4.104    0.039 &lt;frozen importlib._bootstrap&gt;:1156(_load_backward_compatible)
   1414/32    0.034    0.000   23.620    0.738 &lt;frozen importlib._bootstrap&gt;:1186(_load_unlocked)
     15    0.000    0.000    0.002    0.000 &lt;frozen importlib._bootstrap&gt;:1223(_fix_up_module)
   1650    0.002    0.000    0.006    0.000 &lt;frozen importlib._bootstrap&gt;:1266(find_spec)
     19    0.000    0.000    0.006    0.000 &lt;frozen importlib._bootstrap&gt;:1287(load_module)
   1245    0.019    0.000    0.019    0.000 &lt;frozen importlib._bootstrap&gt;:129(_new_module)
     19    0.000    0.000    0.000    0.000 &lt;frozen importlib._bootstrap&gt;:1311(is_package)
   1631    0.004    0.000    0.009    0.000 &lt;frozen importlib._bootstrap&gt;:1336(find_spec)
   1631    0.022    0.000    0.254    0.000 &lt;frozen importlib._bootstrap&gt;:1401(_open_registry)
   1631    0.034    0.000    0.307    0.000 &lt;frozen importlib._bootstrap&gt;:1408(_search_registry)
    139    0.000    0.000    0.000    0.000 &lt;frozen importlib._bootstrap&gt;:141(__init__)
   1631    0.006    0.000    0.314    0.000 &lt;frozen importlib._bootstrap&gt;:1423(find_spec)
    139    0.000    0.000    0.000    0.000 &lt;frozen importlib._bootstrap&gt;:144(__enter__)
    1245/32    0.022    0.000   23.612    0.738 &lt;frozen importlib._bootstrap&gt;:1465(exec_module)
    139    0.001    0.000    0.003    0.000 &lt;frozen importlib._bootstrap&gt;:147(__exit__)
    556    0.001    0.000    0.001    0.000 &lt;frozen importlib._bootstrap&gt;:148(&lt;genexpr&gt;)
   1245    0.055    0.000    2.437    0.002 &lt;frozen importlib._bootstrap&gt;:1534(get_code)
   1245    0.008    0.000    0.008    0.000 &lt;frozen importlib._bootstrap&gt;:1591(__init__)
   1245    0.001    0.000    0.001    0.000 &lt;frozen importlib._bootstrap&gt;:1616(get_filename)
   1245    0.941    0.001    1.037    0.001 &lt;frozen importlib._bootstrap&gt;:1621(get_data)
   1245    0.011    0.000    0.384    0.000 &lt;frozen importlib._bootstrap&gt;:1631(path_stats)
    120    0.001    0.000    0.001    0.000 &lt;frozen importlib._bootstrap&gt;:1697(__init__)
    120/92    0.004    0.000    4.087    0.044 &lt;frozen importlib._bootstrap&gt;:1708(load_module)
   1888    0.017    0.000    0.066    0.000 &lt;frozen importlib._bootstrap&gt;:172(__init__)
    120    0.001    0.000    0.006    0.000 &lt;frozen importlib._bootstrap&gt;:1726(is_package)
    240    0.001    0.000    0.001    0.000 &lt;frozen importlib._bootstrap&gt;:1729(&lt;genexpr&gt;)
    181    0.058    0.000    0.128    0.001 &lt;frozen importlib._bootstrap&gt;:1853(_path_hooks)
   2614    0.012    0.000    0.142    0.000 &lt;frozen importlib._bootstrap&gt;:1870(_path_importer_cache)
    135    0.002    0.000    0.461    0.003 &lt;frozen importlib._bootstrap&gt;:1887(_legacy_get_spec)
   1631    0.035    0.000    2.252    0.001 &lt;frozen importlib._bootstrap&gt;:1902(_get_spec)
   2857    0.033    0.000    0.035    0.000 &lt;frozen importlib._bootstrap&gt;:192(acquire)
   1631    0.009    0.000    2.261    0.001 &lt;frozen importlib._bootstrap&gt;:1934(find_spec)
    179    0.006    0.000    0.012    0.000 &lt;frozen importlib._bootstrap&gt;:1979(__init__)
   1253    0.001    0.000    0.001    0.000 &lt;frozen importlib._bootstrap&gt;:1985(&lt;genexpr&gt;)
   1365    0.016    0.000    0.055    0.000 &lt;frozen importlib._bootstrap&gt;:2011(_get_spec)
   2335    0.118    0.000    1.603    0.001 &lt;frozen importlib._bootstrap&gt;:2016(find_spec)
    178    0.016    0.000    0.100    0.001 &lt;frozen importlib._bootstrap&gt;:2061(_fill_cache)
    178    0.003    0.000    0.004    0.000 &lt;frozen importlib._bootstrap&gt;:2090(&lt;setcomp&gt;)
    179    0.002    0.000    0.071    0.000 &lt;frozen importlib._bootstrap&gt;:2102(path_hook_for_FileFinder)
   7719    0.012    0.000    0.017    0.000 &lt;frozen importlib._bootstrap&gt;:2120(__enter__)
   7719    0.013    0.000    0.020    0.000 &lt;frozen importlib._bootstrap&gt;:2124(__exit__)
   1176    0.007    0.000    0.019    0.000 &lt;frozen importlib._bootstrap&gt;:2138(_find_spec_legacy)
  1650/1648    0.097    0.000    2.739    0.002 &lt;frozen importlib._bootstrap&gt;:2147(_find_spec)
   2857    0.031    0.000    0.033    0.000 &lt;frozen importlib._bootstrap&gt;:217(release)
    216    0.001    0.000    0.001    0.000 &lt;frozen importlib._bootstrap&gt;:2187(_sanity_check)
   1730/92    0.045    0.000   23.736    0.258 &lt;frozen importlib._bootstrap&gt;:2207(_find_and_load_unlocked)
   1730/92    0.057    0.000   23.753    0.258 &lt;frozen importlib._bootstrap&gt;:2234(_find_and_load)
   216/214    0.004    0.000    0.051    0.000 &lt;frozen importlib._bootstrap&gt;:2240(_gcd_import)
  338220/334774    1.206    0.000   10.385    0.000 &lt;frozen importlib._bootstrap&gt;:2264(_handle_fromlist)
  108/107    0.001    0.000    0.052    0.000 &lt;frozen importlib._bootstrap&gt;:2322(__import__)
   1730    0.006    0.000    0.006    0.000 &lt;frozen importlib._bootstrap&gt;:257(__init__)
   1730    0.017    0.000    0.134    0.000 &lt;frozen importlib._bootstrap&gt;:261(__enter__)
   1730    0.007    0.000    0.033    0.000 &lt;frozen importlib._bootstrap&gt;:268(__exit__)
   2857    0.040    0.000    0.106    0.000 &lt;frozen importlib._bootstrap&gt;:274(_get_module_lock)
   1888    0.003    0.000    0.003    0.000 &lt;frozen importlib._bootstrap&gt;:288(cb)
   1127    0.011    0.000    0.044    0.000 &lt;frozen importlib._bootstrap&gt;:293(_lock_unlock_module)
   2335    0.007    0.000    0.007    0.000 &lt;frozen importlib._bootstrap&gt;:30(_relax_case)
   1804/32    0.007    0.000   23.649    0.739 &lt;frozen importlib._bootstrap&gt;:313(_call_with_frames_removed)
   2490    0.035    0.000    0.140    0.000 &lt;frozen importlib._bootstrap&gt;:437(cache_from_source)
   2490    0.008    0.000    0.014    0.000 &lt;frozen importlib._bootstrap&gt;:45(_r_long)
   9163    0.047    0.000    0.132    0.000 &lt;frozen importlib._bootstrap&gt;:50(_path_join)
   9990    0.024    0.000    0.024    0.000 &lt;frozen importlib._bootstrap&gt;:518(_verbose_message)
   9163    0.050    0.000    0.071    0.000 &lt;frozen importlib._bootstrap&gt;:52(&lt;listcomp&gt;)
   1365/1155    0.007    0.000    4.094    0.004 &lt;frozen importlib._bootstrap&gt;:534(_check_name_wrapper)
     38    0.000    0.000    0.006    0.000 &lt;frozen importlib._bootstrap&gt;:546(_requires_builtin_wrapper)
   2618    0.042    0.000    0.063    0.000 &lt;frozen importlib._bootstrap&gt;:56(_path_split)
   1245    0.055    0.000    0.070    0.000 &lt;frozen importlib._bootstrap&gt;:599(_validate_bytecode_header)
   1245    0.017    0.000    0.823    0.001 &lt;frozen importlib._bootstrap&gt;:654(_compile_bytecode)
   5307    0.020    0.000    1.598    0.000 &lt;frozen importlib._bootstrap&gt;:68(_path_stat)
      2    0.000    0.000    0.000    0.000 &lt;frozen importlib._bootstrap&gt;:690(_module_repr)
   1245    0.003    0.000    0.003    0.000 &lt;frozen importlib._bootstrap&gt;:728(__init__)
   1245    0.004    0.000    0.004    0.000 &lt;frozen importlib._bootstrap&gt;:732(__enter__)
   1245    0.017    0.000    0.032    0.000 &lt;frozen importlib._bootstrap&gt;:739(__exit__)
   4980    0.005    0.000    0.005    0.000 &lt;frozen importlib._bootstrap&gt;:742(&lt;genexpr&gt;)
   1727    0.014    0.000    0.597    0.000 &lt;frozen importlib._bootstrap&gt;:78(_path_is_mode_type)
   1801    0.016    0.000    0.016    0.000 &lt;frozen importlib._bootstrap&gt;:790(__init__)
   2490    0.017    0.000    0.104    0.000 &lt;frozen importlib._bootstrap&gt;:824(cached)
   1245    0.008    0.000    0.010    0.000 &lt;frozen importlib._bootstrap&gt;:842(parent)
   1247    0.001    0.000    0.001    0.000 &lt;frozen importlib._bootstrap&gt;:850(has_location)
  49/48    0.001    0.000    0.464    0.010 &lt;frozen importlib._bootstrap&gt;:859(spec_from_loader)
   1547    0.006    0.000    0.547    0.000 &lt;frozen importlib._bootstrap&gt;:87(_path_isfile)
   1395    0.020    0.000    0.487    0.000 &lt;frozen importlib._bootstrap&gt;:884(spec_from_file_location)
    180    0.001    0.000    0.057    0.000 &lt;frozen importlib._bootstrap&gt;:92(_path_isdir)
      1    0.000    0.000    0.000    0.000 &lt;string&gt;:1(&lt;module&gt;)
      1    0.000    0.000    0.000    0.000 &lt;string&gt;:1(error)
      1    0.000    0.000    0.000    0.000 &lt;string&gt;:11(com_error)
    313    0.001    0.000    0.001    0.000 &lt;string&gt;:12(__new__)
      1    0.000    0.000    0.000    0.000 &lt;string&gt;:2(&lt;module&gt;)
      1    0.000    0.000    0.000    0.000 &lt;string&gt;:2(__init__)
      4    0.000    0.000    0.000    0.000 &lt;string&gt;:2(_parse_args)
      1    0.000    0.000    0.000    0.000 &lt;string&gt;:5(AndersonResult)
      1    0.000    0.000    0.000    0.000 &lt;string&gt;:5(Anderson_ksampResult)
      1    0.000    0.000    0.000    0.000 &lt;string&gt;:5(AnsariResult)
      1    0.000    0.000    0.000    0.000 &lt;string&gt;:5(ArgInfo)
      1    0.000    0.000    0.000    0.000 &lt;string&gt;:5(ArgSpec)
      1    0.000    0.000    0.000    0.000 &lt;string&gt;:5(Arguments)
      1    0.000    0.000    0.000    0.000 &lt;string&gt;:5(ArrayFormula)
      1    0.000    0.000    0.000    0.000 &lt;string&gt;:5(Attribute)
      1    0.000    0.000    0.000    0.000 &lt;string&gt;:5(BartlettResult)
      1    0.000    0.000    0.000    0.000 &lt;string&gt;:5(BinnedStatistic2dResult)
      1    0.000    0.000    0.000    0.000 &lt;string&gt;:5(FlignerResult)
      1    0.000    0.000    0.000    0.000 &lt;string&gt;:5(Formula)
      1    0.002    0.002    0.002    0.002 &lt;string&gt;:5(FriedmanchisquareResult)
      1    0.000    0.000    0.000    0.000 &lt;string&gt;:5(FullArgSpec)
      1    0.000    0.000    0.000    0.000 &lt;string&gt;:5(FunctionAttributes)
      1    0.000    0.000    0.000    0.000 &lt;string&gt;:5(HistogramResult)
  19424    2.346    0.000    2.346    0.000 {pandas.algos.take_2d_axis1_object_object}
  82904    0.318    0.000    0.318    0.000 {pandas.index.get_value_at}
    199    0.051    0.000    0.051    0.000 {pandas.lib.clean_index_list}
     57    0.002    0.000    0.002    0.000 {pandas.lib.get_blkno_indexers}
   2918    0.095    0.000    0.095    0.000 {pandas.lib.infer_dtype}
     38    0.001    0.000    0.001    0.000 {pandas.lib.is_bool_array}
     76    0.000    0.000    0.000    0.000 {pandas.lib.is_bool}
  166001    0.169    0.000    0.169    0.000 {pandas.lib.is_float}
  249112    0.215    0.000    0.215    0.000 {pandas.lib.is_integer}
     20    0.000    0.000    0.000    0.000 {pandas.lib.is_timedelta_array}
     38    0.002    0.000    0.002    0.000 {pandas.lib.isnullobj}
  414822    1.023    0.000    1.023    0.000 {pandas.lib.isscalar}
     11    0.054    0.005    0.054    0.005 {pandas.lib.maybe_convert_numeric}
     56    0.006    0.000    0.006    0.000 {pandas.lib.maybe_convert_objects}
      3    0.000    0.000    0.018    0.006 {pandas.lib.reduce}
     65    0.009    0.000    0.105    0.002 {pandas.lib.scalar_compare}
     28    0.001    0.000    0.001    0.000 {pandas.lib.to_object_array_tuples}
  415734    2.533    0.000    4.116    0.000 {pandas.lib.values_from_object}
     20    0.000    0.000    0.000    0.000 {pandas.tslib.is_timestamp_array}
     48    0.001    0.000    0.001    0.000 {reduce.nansum}
  </code></pre>