Pangloss Performance Benchmark


In [4]:
from pangloss import BackgroundCatalog, ForegroundCatalog, \
    TrueHaloMassDistribution, Kappamap, Shearmap

ITERATIONS = 4
RADIUS = 2.0

# initialize background and foreground
B = BackgroundCatalog(N=10.0, domain=[1.5, 1.4, -1.5, -1.4], field=[0, 0, 0, 0])
F = ForegroundCatalog.guo()
F.set_mass_prior(TrueHaloMassDistribution())

# initialize maps from Hilbert et al 2009
K = Kappamap.example()
S = Shearmap.example()

# run monte carlo samples
def pangloss_benchmark():
    for _ in xrange(ITERATIONS):
        F.draw_halo_masses()
        B.drill_lightcones(radius=RADIUS, foreground=F, smooth_corr=False)
        B.lens_by_map(K, S)
        B.lens_by_halos(lookup_table=False, smooth_corr=False, relevance_lim=0)
        B.halo_mass_log_likelihood()


['$PANGLOSS_DIR/calib/Millennium/catalog_example.txt']
['$PANGLOSS_DIR/calib/Millennium/GGL_los*.fits']
         45253159 function calls (44562463 primitive calls) in 164.629 seconds

   Ordered by: standard name

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.031    0.031  164.629  164.629 <ipython-input-4-3d073afda2ed>:18(pangloss_benchmark)
        1    0.000    0.000  164.629  164.629 <string>:1(<module>)
    90817    0.073    0.000    0.104    0.000 __init__.py:163(iteritems)
     5764    0.006    0.000    0.007    0.000 __init__.py:169(itervalues)
       12    0.000    0.000    0.001    0.000 _methods.py:122(_std)
     2880    0.010    0.000    0.659    0.000 _methods.py:25(_amax)
     2880    0.010    0.000    0.675    0.000 _methods.py:28(_amin)
    17296    0.022    0.000    2.586    0.000 _methods.py:31(_sum)
    56312    0.052    0.000    0.473    0.000 _methods.py:37(_any)
     2908    0.003    0.000    0.030    0.000 _methods.py:40(_all)
       20    0.000    0.000    0.000    0.000 _methods.py:43(_count_reduce_items)
        8    0.000    0.000    0.000    0.000 _methods.py:53(_mean)
       12    0.000    0.000    0.001    0.000 _methods.py:76(_var)
    23040    0.036    0.000    0.036    0.000 _weakrefset.py:70(__contains__)
    11520    0.067    0.000    0.107    0.000 abc.py:128(__instancecheck__)
        4    0.000    0.000    0.000    0.000 algorithms.py:779(wrapper)
        4    0.000    0.000    0.000    0.000 algorithms.py:822(_take_nd_generic)
    21633    0.048    0.000    0.068    0.000 algorithms.py:946(_get_take_nd_function)
        4    0.000    0.000    0.000    0.000 algorithms.py:971(func)
    21633    0.355    0.000    2.169    0.000 algorithms.py:979(take_nd)
    11520    0.003    0.000    0.003    0.000 arrayprint.py:227(_boolFormatter)
       32    0.001    0.000    0.110    0.003 arrayprint.py:237(_array2string)
    96/32    0.001    0.000    0.110    0.003 arrayprint.py:340(array2string)
    11520    0.015    0.000    0.021    0.000 arrayprint.py:450(_extendLine)
       32    0.015    0.000    0.039    0.001 arrayprint.py:458(_formatArray)
       96    0.000    0.000    0.068    0.001 arrayprint.py:529(__init__)
       96    0.017    0.000    0.067    0.001 arrayprint.py:543(fillFormat)
    23040    0.034    0.000    0.045    0.000 arrayprint.py:628(_digits)
       32    0.000    0.000    0.001    0.000 arrayprint.py:635(__init__)
       96    0.000    0.000    0.000    0.000 arrayprint.py:657(__init__)
       32    0.000    0.000    0.000    0.000 arrayprint.py:685(__init__)
       32    0.000    0.000    0.033    0.001 arrayprint.py:696(__init__)
       32    0.000    0.000    0.000    0.000 arrayprint.py:713(__init__)
       32    0.000    0.000    0.000    0.000 arrayprint.py:734(__init__)
        4    0.027    0.007    0.539    0.135 background.py:231(lens_by_map)
        4    0.123    0.031   26.714    6.679 background.py:299(lens_by_halos)
        4    0.000    0.000    0.044    0.011 background.py:499(setup_grid)
     1440    0.060    0.000    3.301    0.002 background.py:509(set_relevance)
        4    0.171    0.043  137.288   34.322 background.py:546(drill_lightcones)
        4    0.000    0.000    0.003    0.001 background.py:914(halo_mass_log_likelihood)
    18726    0.017    0.000    0.017    0.000 base.py:1067(is_unique)
        4    0.000    0.000    0.000    0.000 base.py:1079(is_integer)
    11556    0.028    0.000    0.072    0.000 base.py:1101(_convert_scalar_indexer)
        4    0.000    0.000    0.000    0.000 base.py:1220(_convert_list_indexer)
    41793    0.109    0.000    0.179    0.000 base.py:1272(_engine)
   245182    0.254    0.000    0.905    0.000 base.py:1275(<lambda>)
        1    0.000    0.000    0.000    0.000 base.py:1301(inferred_type)
        4    0.000    0.000    0.000    0.000 base.py:1315(__iter__)
   186000    1.731    0.000    2.547    0.000 base.py:1362(__contains__)
    41849    0.097    0.000    0.109    0.000 base.py:1376(__getitem__)
112380/74920    1.919    0.000    7.702    0.000 base.py:142(__new__)
     7208    0.061    0.000    0.360    0.000 base.py:1476(take)
        4    0.000    0.000    0.000    0.000 base.py:1493(_assert_take_fillable)
    74918    0.122    0.000    0.554    0.000 base.py:1613(equals)
   121154    0.358    0.000    2.022    0.000 base.py:2074(get_loc)
    11552    0.060    0.000    0.491    0.000 base.py:2116(get_value)
        4    0.000    0.000    0.001    0.000 base.py:2187(get_indexer)
        4    0.000    0.000    0.000    0.000 base.py:2360(_possibly_promote)
    49008    0.048    0.000    0.064    0.000 base.py:2972(_maybe_cast_indexer)
    37456    0.269    0.000    9.239    0.000 base.py:3188(insert)
    90809    0.349    0.000    0.605    0.000 base.py:334(_simple_new)
   206097    0.186    0.000    0.280    0.000 base.py:3602(_ensure_index)
    15888    0.060    0.000    0.284    0.000 base.py:371(_shallow_copy)
    37456    0.146    0.000    3.144    0.000 base.py:379(_shallow_copy_with_infer)
    74918    0.095    0.000    0.114    0.000 base.py:435(is_)
    90817    0.082    0.000    0.082    0.000 base.py:455(_reset_identity)
   586772    0.348    0.000    0.442    0.000 base.py:461(__len__)
    37456    0.036    0.000    0.060    0.000 base.py:467(__array__)
    44685    0.025    0.000    0.025    0.000 base.py:482(dtype)
   312968    0.320    0.000    0.571    0.000 base.py:492(values)
    14464    0.013    0.000    0.038    0.000 base.py:497(get_values)
    90800    0.343    0.000    0.369    0.000 base.py:576(_get_attributes_dict)
     8656    0.020    0.000    0.161    0.000 base.py:580(view)
    37456    0.200    0.000    5.236    0.000 base.py:592(_coerce_scalar_to_index)
    11520    0.004    0.000    0.004    0.000 base.py:819(ndim)
   282643    0.227    0.000    0.741    0.000 base.py:874(_values)
    21620    0.152    0.000    0.662    0.000 cast.py:227(_maybe_promote)
     1440    0.017    0.000    0.650    0.000 cast.py:486(_astype_nansafe)
   109516    0.225    0.000    0.225    0.000 cast.py:660(_possibly_castable)
    15844    0.295    0.000    0.505    0.000 cast.py:765(_possibly_cast_to_datetime)
    77820    0.056    0.000    0.056    0.000 collections.py:90(__iter__)
   449629    0.443    0.000    2.191    0.000 common.py:100(is_categorical_dtype)
    17340    0.033    0.000    0.062    0.000 common.py:104(is_string_dtype)
       16    0.000    0.000    0.000    0.000 common.py:127(is_datetimelike)
    21628    0.041    0.000    0.078    0.000 common.py:133(is_dtype_equal)
    33144    0.080    0.000    0.155    0.000 common.py:136(_maybe_match_name)
    61953    0.079    0.000    0.144    0.000 common.py:151(is_integer_dtype)
    18724    0.044    0.000    0.084    0.000 common.py:162(is_int_or_datetime_dtype)
   112376    0.108    0.000    0.876    0.000 common.py:168(is_datetime64_any_dtype)
     7276    0.034    0.000    0.099    0.000 common.py:185(is_bool_indexer)
    79304    0.120    0.000    0.551    0.000 common.py:186(is_datetime_or_timedelta_dtype)
    17312    0.066    0.000    0.699    0.000 common.py:215(is_datetimelike_v_numeric)
        4    0.000    0.000    0.000    0.000 common.py:244(_count_not_none)
       12    0.000    0.000    0.000    0.000 common.py:245(<genexpr>)
    66340    0.119    0.000    1.084    0.000 common.py:248(needs_i8_conversion)
    85020    0.102    0.000    0.251    0.000 common.py:266(is_float_dtype)
    87884    0.100    0.000    0.388    0.000 common.py:276(is_bool_dtype)
    90876    0.194    0.000    1.783    0.000 common.py:285(is_extension_type)
     1468    0.002    0.000    0.007    0.000 common.py:299(is_complex_dtype)
    31688    0.115    0.000    0.845    0.000 common.py:304(_coerce_to_dtype)
    60596    0.048    0.000    0.065    0.000 common.py:317(_get_dtype)
   817145    1.417    0.000    2.848    0.000 common.py:341(_get_dtype_type)
   112384    0.777    0.000    1.568    0.000 common.py:356(_asarray_tuplesafe)
   122564    0.110    0.000    0.135    0.000 common.py:438(_apply_if_callable)
    39008    0.073    0.000    0.225    0.000 common.py:52(is_object_dtype)
    98112    0.067    0.000    0.473    0.000 common.py:57(is_sparse)
   112509    0.133    0.000    0.836    0.000 common.py:62(is_categorical)
   155832    0.144    0.000    0.953    0.000 common.py:67(is_datetimetz)
   229092    0.272    0.000    1.261    0.000 common.py:79(is_datetime64_dtype)
   454144    0.333    0.000    1.969    0.000 common.py:87(is_datetime64tz_dtype)
   214692    0.234    0.000    1.238    0.000 common.py:91(is_timedelta64_dtype)
    98028    0.090    0.000    0.535    0.000 common.py:96(is_period_dtype)
     1440    0.003    0.000    0.035    0.000 config.py:222(__call__)
     1440    0.002    0.000    0.002    0.000 config.py:527(_select_options)
     1440    0.004    0.000    0.007    0.000 config.py:545(_get_root)
     2880    0.007    0.000    0.007    0.000 config.py:560(_get_deprecated_option)
     1440    0.002    0.000    0.004    0.000 config.py:588(_translate_key)
     1440    0.003    0.000    0.008    0.000 config.py:601(_warn_if_deprecated)
     1440    0.006    0.000    0.021    0.000 config.py:78(_get_single_key)
     1440    0.005    0.000    0.032    0.000 config.py:96(_get_option)
      400    0.001    0.000    0.001    0.000 distances.py:116(Hsquared)
      400    0.000    0.000    0.001    0.000 distances.py:123(rho_crit_univ)
        4    0.000    0.000    0.000    0.000 distances.py:17(__init__)
     1212    0.006    0.000    0.037    0.000 distances.py:52(comoving_distance)
    25452    0.014    0.000    0.014    0.000 distances.py:68(<lambda>)
     1212    0.002    0.000    0.039    0.000 distances.py:75(comoving_transverse_distance)
     1212    0.002    0.000    0.040    0.000 distances.py:89(angular_diameter_distance)
        4    0.017    0.004    0.047    0.012 distribution.py:15(draw)
   119580    0.204    0.000    0.204    0.000 dtypes.py:132(construct_from_string)
    23048    0.102    0.000    0.146    0.000 dtypes.py:170(__new__)
    23048    0.102    0.000    0.249    0.000 dtypes.py:221(construct_from_string)
    98028    0.234    0.000    0.446    0.000 dtypes.py:347(is_dtype)
   985957    1.563    0.000    3.538    0.000 dtypes.py:74(is_dtype)
    72064    0.075    0.000    0.075    0.000 expressions.py:162(_has_bool_dtype)
    72064    0.094    0.000    0.169    0.000 expressions.py:172(_bool_arith_check)
    72064    0.176    0.000    2.253    0.000 expressions.py:191(evaluate)
    72064    0.363    0.000    1.909    0.000 expressions.py:58(_evaluate_standard)
        4    0.001    0.000    0.055    0.014 foreground.py:250(draw_halo_masses)
    73496    0.521    0.000   15.915    0.000 frame.py:2033(__getitem__)
    66288    0.159    0.000    5.318    0.000 frame.py:2059(_getitem_column)
     7208    0.076    0.000    8.425    0.001 frame.py:2076(_getitem_array)
    41817    0.172    0.000    2.357    0.000 frame.py:2391(_box_item_values)
    41817    0.106    0.000    1.519    0.000 frame.py:2398(_box_col_values)
    37516    0.217    0.000  100.781    0.003 frame.py:2403(__setitem__)
    11532    0.006    0.000    0.006    0.000 frame.py:241(_constructor)
    37516    0.046    0.000    0.102    0.000 frame.py:2454(_ensure_valid_index)
    37516    0.248    0.000   99.496    0.003 frame.py:2471(_set_item)
    11532    0.087    0.000    0.167    0.000 frame.py:252(__init__)
    37516    0.382    0.000    2.268    0.000 frame.py:2591(_sanitize_column)
    28800    0.110    0.000    0.368    0.000 frame.py:2595(reindexer)
        4    0.000    0.000    0.096    0.024 frame.py:2813(rename)
    44720    0.053    0.000    0.131    0.000 frame.py:769(__len__)
    74944    0.132    0.000    0.420    0.000 fromnumeric.py:1383(ravel)
     2880    0.003    0.000    0.003    0.000 fromnumeric.py:1574(shape)
     5772    0.034    0.000    1.327    0.000 fromnumeric.py:1743(sum)
       96    0.000    0.000    0.002    0.000 fromnumeric.py:1900(any)
     2880    0.024    0.000    5.307    0.002 fromnumeric.py:2200(amax)
     2880    0.025    0.000    5.394    0.002 fromnumeric.py:2300(amin)
        8    0.000    0.000    0.000    0.000 fromnumeric.py:2843(mean)
        4    0.000    0.000    0.000    0.000 fromnumeric.py:2945(std)
     4323    0.007    0.000    0.027    0.000 fromnumeric.py:828(argsort)
    27380    0.079    0.000    0.443    0.000 function.py:37(__call__)
    74912    0.207    0.000    0.930    0.000 function_base.py:4534(append)
        4    0.000    0.000    0.000    0.000 function_base.py:9(linspace)
   185937    0.455    0.000    0.455    0.000 generic.py:114(__init__)
    15844    0.043    0.000    0.674    0.000 generic.py:131(_validate_dtype)
        4    0.000    0.000    0.000    0.000 generic.py:1348(_indexer)
    66288    0.288    0.000    5.143    0.000 generic.py:1381(_get_item_cache)
    41817    0.121    0.000    0.260    0.000 generic.py:1395(_set_as_cached)
    11532    0.027    0.000    0.035    0.000 generic.py:144(_init_mgr)
    41842    0.054    0.000    0.149    0.000 generic.py:1477(_clear_item_cache)
    37516    0.227    0.000   14.585    0.000 generic.py:1499(_set_item)
     5764    0.018    0.000    0.029    0.000 generic.py:1503(_set_is_copy)
    37516    0.059    0.000   82.127    0.002 generic.py:1533(_check_setitem_copy)
     7208    0.146    0.000    7.745    0.001 generic.py:1650(take)
    50456    0.137    0.000    0.284    0.000 generic.py:2713(__finalize__)
   217669    0.485    0.000    0.486    0.000 generic.py:2730(__getattr__)
   289752    1.301    0.000    2.479    0.000 generic.py:2746(__setattr__)
    24504    0.067    0.000    2.446    0.000 generic.py:2785(_protect_consolidate)
    24504    0.041    0.000    2.487    0.000 generic.py:2795(_consolidate_inplace)
    24504    0.066    0.000    2.345    0.000 generic.py:2798(f)
        4    0.000    0.000    0.000    0.000 generic.py:280(_construct_axes_from_arguments)
     5772    0.014    0.000    0.142    0.000 generic.py:2868(as_matrix)
    11520    0.095    0.000    2.428    0.000 generic.py:3007(astype)
     4324    0.034    0.000    1.091    0.000 generic.py:3057(copy)
    11520    0.302    0.000    3.373    0.000 generic.py:3200(fillna)
    31696    0.099    0.000    0.119    0.000 generic.py:327(_get_axis_number)
    25944    0.048    0.000    0.067    0.000 generic.py:340(_get_axis_name)
    25944    0.036    0.000    0.122    0.000 generic.py:353(_get_axis)
     7212    0.015    0.000    0.043    0.000 generic.py:357(_get_block_manager_axis)
       16    0.000    0.000    0.000    0.000 generic.py:401(_info_axis)
        1    0.000    0.000    0.000    0.000 generic.py:421(ndim)
    11524    0.097    0.000   11.942    0.001 generic.py:5599(stat_func)
     1440    0.011    0.000    0.224    0.000 generic.py:5674(logical_func)
        4    0.000    0.000    0.096    0.024 generic.py:640(rename)
        4    0.000    0.000    0.000    0.000 generic.py:656(_get_rename_function)
       32    0.000    0.000    0.000    0.000 generic.py:659(f)
   796182    0.557    0.000    1.323    0.000 generic.py:7(_check)
     4320    0.019    0.000    0.373    0.000 generic.py:797(__neg__)
     7204    0.020    0.000    0.040    0.000 generic.py:829(__hash__)
     1444    0.030    0.000    0.088    0.000 grid.py:153(snap)
        4    0.002    0.001    0.044    0.011 grid.py:45(__init__)
        4    0.000    0.000    0.002    0.000 indexing.py:1115(_convert_to_indexer)
    44724    0.220    0.000    1.001    0.000 indexing.py:1768(convert_to_index_sliceable)
     7236    0.033    0.000    0.246    0.000 indexing.py:1805(check_bool_indexer)
     7208    0.142    0.000    0.250    0.000 indexing.py:1856(maybe_convert_indices)
        4    0.000    0.000    0.000    0.000 indexing.py:1892(is_nested_tuple)
        4    0.000    0.000    0.000    0.000 indexing.py:1906(is_list_like_indexer)
        4    0.000    0.000    0.000    0.000 indexing.py:191(_convert_scalar_indexer)
        1    0.000    0.000    0.000    0.000 indexing.py:58(__init__)
       32    0.000    0.000    0.000    0.000 inference.py:35(is_iterator)
    14404    0.014    0.000    0.029    0.000 inference.py:53(is_list_like)
   119637    0.111    0.000    0.132    0.000 inference.py:66(is_hashable)
     8716    0.020    0.000    0.030    0.000 inference.py:98(is_sequence)
    21624    0.165    0.000    2.689    0.000 internals.py:1003(take_nd)
    66282    0.058    0.000    0.080    0.000 internals.py:112(_consolidate_key)
    11520    0.020    0.000    0.149    0.000 internals.py:130(is_categorical_astype)
   155648    0.042    0.000    0.042    0.000 internals.py:145(external_values)
    64860    0.026    0.000    0.026    0.000 internals.py:149(internal_values)
     1440    0.010    0.000    0.015    0.000 internals.py:1533(_can_hold_element)
     7212    0.010    0.000    0.071    0.000 internals.py:155(get_values)
       46    0.000    0.000    0.000    0.000 internals.py:1578(should_store)
        6    0.000    0.000    0.000    0.000 internals.py:1604(should_store)
        1    0.000    0.000    0.000    0.000 internals.py:1627(should_store)
    53340    0.052    0.000    0.095    0.000 internals.py:164(to_dense)
    21624    0.014    0.000    0.014    0.000 internals.py:176(fill_value)
        7    0.000    0.000    0.000    0.000 internals.py:1772(should_store)
    11532    0.058    0.000    0.116    0.000 internals.py:1790(__init__)
   471289    0.144    0.000    0.144    0.000 internals.py:180(mgr_locs)
     2880    0.014    0.000    0.058    0.000 internals.py:191(make_block)
    96585    0.257    0.000    1.121    0.000 internals.py:209(make_block_same_class)
   252233    0.425    0.000    0.599    0.000 internals.py:217(mgr_locs)
       32    0.000    0.000    0.000    0.000 internals.py:251(_slice)
   252233    0.905    0.000    2.788    0.000 internals.py:2628(make_block)
    15858    0.161    0.000    1.853    0.000 internals.py:2724(__init__)
    96618    0.366    0.000    0.758    0.000 internals.py:2765(shape)
   289854    0.118    0.000    0.393    0.000 internals.py:2767(<genexpr>)
   149935    0.091    0.000    0.113    0.000 internals.py:2769(ndim)
        4    0.000    0.000    0.000    0.000 internals.py:2773(set_axis)
        4    0.000    0.000    0.041    0.010 internals.py:2785(rename_axis)
     5776    0.003    0.000    0.003    0.000 internals.py:2808(_is_single_block)
    20180    0.586    0.000    1.328    0.000 internals.py:2820(_rebuild_blknos_and_blklocs)
   289768    0.101    0.000    0.101    0.000 internals.py:2841(_get_items)
    59085    0.027    0.000    0.027    0.000 internals.py:290(shape)
     7204    0.011    0.000    0.025    0.000 internals.py:2930(__len__)
    11530    0.108    0.000    0.351    0.000 internals.py:2945(_verify_integrity)
    66295    0.047    0.000    0.076    0.000 internals.py:2947(<genexpr>)
    27368    0.414    0.000    4.807    0.000 internals.py:2957(apply)
   557834    0.217    0.000    0.217    0.000 internals.py:298(dtype)
    27368    0.019    0.000    0.031    0.000 internals.py:3016(<genexpr>)
   100890    0.139    0.000    0.172    0.000 internals.py:302(ftype)
    11520    0.053    0.000    2.277    0.000 internals.py:3161(fillna)
    11520    0.043    0.000    1.796    0.000 internals.py:3167(astype)
    34606    0.027    0.000    0.141    0.000 internals.py:3226(is_consolidated)
    20180    0.143    0.000    0.321    0.000 internals.py:3234(_consolidate_check)
    41817    0.056    0.000    0.056    0.000 internals.py:327(iget)
       59    0.002    0.000    0.002    0.000 internals.py:330(set)
        3    0.000    0.000    0.000    0.000 internals.py:3337(nblocks)
     4328    0.031    0.000    1.034    0.000 internals.py:3341(copy)
     8656    0.011    0.000    0.173    0.000 internals.py:3361(<lambda>)
     5772    0.017    0.000    0.083    0.000 internals.py:3368(as_matrix)
    24504    0.052    0.000    2.189    0.000 internals.py:3490(consolidate)
    27394    0.046    0.000    1.355    0.000 internals.py:3506(_consolidate_inplace)
    41817    0.213    0.000    2.174    0.000 internals.py:3513(get)
    41817    0.365    0.000    1.156    0.000 internals.py:3542(iget)
    11520    0.042    0.000    1.870    0.000 internals.py:359(fillna)
    37516    0.438    0.000   14.235    0.000 internals.py:3613(set)
       60    0.000    0.000    0.000    0.000 internals.py:3637(value_getitem)
        2    0.000    0.000    0.000    0.000 internals.py:3689(<genexpr>)
    37456    0.881    0.000   11.868    0.000 internals.py:3725(insert)
     7208    0.111    0.000    3.646    0.001 internals.py:3790(reindex_indexer)
        4    0.000    0.000    0.044    0.011 internals.py:3833(_slice_take_blocks_ax0)
     7208    0.131    0.000    4.531    0.001 internals.py:3920(take)
     1440    0.002    0.000    0.002    0.000 internals.py:399(_maybe_downcast)
   174405    0.760    0.000    2.420    0.000 internals.py:4008(__init__)
   631352    0.219    0.000    0.219    0.000 internals.py:4054(_block)
       32    0.000    0.000    0.003    0.000 internals.py:4108(get_slice)
    23104    0.011    0.000    0.011    0.000 internals.py:4115(index)
   357472    0.420    0.000    0.689    0.000 internals.py:4124(dtype)
   155648    0.189    0.000    0.274    0.000 internals.py:4148(external_values)
    64860    0.103    0.000    0.162    0.000 internals.py:4151(internal_values)
    53340    0.143    0.000    0.281    0.000 internals.py:4154(get_values)
    17292    0.006    0.000    0.006    0.000 internals.py:4174(is_consolidated)
    46080    0.011    0.000    0.011    0.000 internals.py:4180(_consolidate_inplace)
     4322    0.106    0.000    1.030    0.000 internals.py:4488(_consolidate)
    66282    0.048    0.000    0.128    0.000 internals.py:4494(<lambda>)
    12966    0.231    0.000    0.720    0.000 internals.py:4505(_merge_blocks)
    48990    0.089    0.000    0.150    0.000 internals.py:4532(_extend_blocks)
     4323    0.021    0.000    0.237    0.000 internals.py:4558(_vstack)
    11520    0.033    0.000    1.468    0.000 internals.py:459(astype)
    11520    0.097    0.000    1.435    0.000 internals.py:464(_astype)
      136    0.001    0.000    0.001    0.000 internals.py:4640(_get_blkno_placements)
        4    0.000    0.000    0.001    0.000 internals.py:4714(_transform_index)
    37456    0.067    0.000    0.150    0.000 internals.py:5199(_fast_count_smallints)
        4    0.000    0.000    0.000    0.000 internals.py:5210(_preprocess_slice_or_indexer)
     1440    0.001    0.000    0.001    0.000 internals.py:575(_try_coerce_args)
     1440    0.001    0.000    0.001    0.000 internals.py:579(_try_coerce_result)
    33144    0.084    0.000    1.401    0.000 internals.py:609(copy)
     1440    0.033    0.000    0.698    0.000 internals.py:782(putmask)
   252233    0.840    0.000    1.694    0.000 internals.py:97(__init__)
     1440    0.110    0.000    2.077    0.001 lensing.py:123(delta_c)
     2880    0.216    0.000    0.278    0.000 lensing.py:126(F)
     2880    0.069    0.000    0.069    0.000 lensing.py:155(L)
     1440    0.132    0.000    0.340    0.000 lensing.py:255(BMO1Ffunc)
     1440    0.130    0.000    0.285    0.000 lensing.py:278(BMO1Gfunc)
     1440    0.067    0.000    2.981    0.002 lightcone.py:202(defineSystem)
     1440    0.036    0.000    0.036    0.000 lightcone.py:212(loadGrid)
     1440    0.082    0.000    6.358    0.004 lightcone.py:305(snapToGrid)
     1440    0.075    0.000    6.595    0.005 lightcone.py:364(drawConcentrations)
     1440    0.290    0.000   13.178    0.009 lightcone.py:379(makeKappas)
     1440    0.036    0.000    4.094    0.003 lightcone.py:426(combineKappas)
     1440    1.144    0.001  124.035    0.086 lightcone.py:67(__init__)
    14404    2.288    0.000    2.722    0.000 missing.py:120(_isnull_ndarraylike)
     7232    0.033    0.000    0.177    0.000 missing.py:245(array_equivalent)
    73505    0.072    0.000    3.129    0.000 missing.py:27(isnull)
    73505    0.161    0.000    3.057    0.000 missing.py:48(_isnull_new)
        4    0.000    0.000    0.000    0.000 missing.py:564(clean_reindex_fill_method)
    72064    0.039    0.000    0.133    0.000 missing.py:568(fill_zeros)
    11524    0.008    0.000    0.008    0.000 missing.py:66(clean_fill_method)
    12964    0.016    0.000    0.039    0.000 nanops.py:151(_get_fill_value)
    12964    0.195    0.000    6.305    0.000 nanops.py:174(_get_values)
    18724    0.025    0.000    0.108    0.000 nanops.py:228(_na_ok_dtype)
    12964    0.023    0.000    0.156    0.000 nanops.py:232(_view_if_needed)
    11524    0.031    0.000    0.104    0.000 nanops.py:238(_wrap_results)
     1440    0.005    0.000    0.142    0.000 nanops.py:265(nanall)
     5764    0.033    0.000    0.687    0.000 nanops.py:270(nansum)
    11528    0.014    0.000    0.027    0.000 nanops.py:35(check)
     5764    0.068    0.000    0.935    0.000 nanops.py:40(_f)
    17292    0.019    0.000    0.046    0.000 nanops.py:43(<genexpr>)
     5760    0.064    0.000    9.760    0.002 nanops.py:432(reduction)
    11524    0.069    0.000    2.597    0.000 nanops.py:642(_maybe_null_out)
    11524    0.370    0.000   10.820    0.001 nanops.py:75(f)
   211861    0.070    0.000    0.070    0.000 numeric.py:137(is_all_dates)
    11552    0.033    0.000    0.116    0.000 numeric.py:144(_convert_scalar_indexer)
     2880    0.008    0.000    0.026    0.000 numeric.py:148(ones)
    96/32    0.000    0.000    0.110    0.003 numeric.py:1835(array_str)
     1468    0.013    0.000    0.029    0.000 numeric.py:2476(array_equal)
   389280    1.018    0.000    2.264    0.000 numeric.py:2576(seterr)
   389280    0.727    0.000    0.790    0.000 numeric.py:2676(geterr)
        1    0.000    0.000    0.000    0.000 numeric.py:28(__new__)
   194640    0.258    0.000    0.297    0.000 numeric.py:2963(__init__)
   194640    0.276    0.000    1.545    0.000 numeric.py:2967(__enter__)
   194640    0.288    0.000    1.283    0.000 numeric.py:2972(__exit__)
   186172    0.198    0.000    0.926    0.000 numeric.py:414(asarray)
   219210    0.193    0.000    0.402    0.000 numeric.py:484(asanyarray)
     4328    0.056    0.000    0.082    0.000 numeric.py:607(require)
     8656    0.014    0.000    0.017    0.000 numeric.py:676(<genexpr>)
     2880    0.002    0.000    0.003    0.000 numerictypes.py:660(issubclass_)
     2880    0.005    0.000    0.010    0.000 numerictypes.py:728(issubdtype)
     1440    0.039    0.000    0.039    0.000 ops.py:101(<lambda>)
    72064    0.015    0.000    0.015    0.000 ops.py:299(<lambda>)
    72064    0.136    0.000    0.136    0.000 ops.py:302(__init__)
    72064    0.261    0.000    2.384    0.000 ops.py:312(get_op)
    77824    0.129    0.000    0.462    0.000 ops.py:607(_align_method_SERIES)
    72064    0.222    0.000    4.643    0.000 ops.py:628(_construct_result)
    72064    0.247    0.000    2.633    0.000 ops.py:649(na_op)
    72064    0.375    0.000    4.134    0.000 ops.py:673(safe_na_op)
    72064    0.713    0.000   13.053    0.000 ops.py:689(wrapper)
     2888    0.024    0.000    0.024    0.000 ops.py:70(<lambda>)
    15844    2.785    0.000    4.267    0.000 ops.py:749(na_op)
    15844    0.378    0.000    8.845    0.001 ops.py:803(wrapper)
     5760    0.011    0.000    0.392    0.000 ops.py:875(na_op)
     5760    0.134    0.000    7.254    0.001 ops.py:903(wrapper)
    11520    0.139    0.000    6.019    0.001 ops.py:907(<lambda>)
     2880    0.019    0.000    0.019    0.000 ops.py:91(<lambda>)
     2880    0.005    0.000    0.033    0.000 ops.py:93(<lambda>)
     1212    0.001    0.000    0.028    0.000 quadpack.py:362(_quad)
     1212    0.002    0.000    0.030    0.000 quadpack.py:44(quad)
        8    0.000    0.000    0.000    0.000 range.py:124(_simple_new)
        1    0.000    0.000    0.000    0.000 range.py:162(_data)
        1    0.000    0.000    0.000    0.000 range.py:166(_int64index)
        8    0.000    0.000    0.000    0.000 range.py:170(_get_data_as_items)
     1453    0.008    0.000    0.042    0.000 range.py:249(_shallow_copy)
     8642    0.022    0.000    0.060    0.000 range.py:286(equals)
        8    0.000    0.000    0.000    0.000 range.py:44(__new__)
    62035    0.094    0.000    0.128    0.000 range.py:455(__len__)
        4    0.000    0.000    0.000    0.000 range.py:465(__getitem__)
     1440    0.087    0.000    1.299    0.001 scalingrelations.py:48(MCrelation)
       16    0.000    0.000    0.000    0.000 series.py:1088(__iter__)
   174405    1.859    0.000   10.913    0.000 series.py:134(__init__)
    12964    0.193    0.000   11.809    0.001 series.py:2301(_reduce)
    11520    0.079    0.000    3.452    0.000 series.py:2362(fillna)
    41817    0.137    0.000    1.413    0.000 series.py:250(from_array)
   116744    0.034    0.000    0.034    0.000 series.py:261(_constructor)
     8716    0.029    0.000    0.050    0.000 series.py:2789(_sanitize_index)
   109516    0.695    0.000    2.710    0.000 series.py:2815(_sanitize_array)
   109516    0.212    0.000    1.314    0.000 series.py:2832(_try_cast)
   174405    0.542    0.000    0.729    0.000 series.py:284(_set_axis)
   174405    0.130    0.000    0.130    0.000 series.py:310(_set_subtyp)
   416513    0.462    0.000    0.878    0.000 series.py:320(name)
   213325    0.320    0.000    0.452    0.000 series.py:324(name)
   357472    0.306    0.000    0.995    0.000 series.py:331(dtype)
   155648    0.119    0.000    0.393    0.000 series.py:351(values)
    64860    0.071    0.000    0.233    0.000 series.py:384(_values)
    53340    0.058    0.000    0.339    0.000 series.py:389(get_values)
     7204    0.006    0.000    0.044    0.000 series.py:461(__len__)
    21624    0.025    0.000    0.168    0.000 series.py:471(__array__)
    15848    0.077    0.000    1.120    0.000 series.py:477(__array_wrap__)
    11528    0.026    0.000    0.063    0.000 series.py:484(__array_prepare__)
    11552    0.037    0.000    0.545    0.000 series.py:598(__getitem__)
       32    0.000    0.000    0.006    0.000 series.py:644(_get_with)
       32    0.000    0.000    0.005    0.000 series.py:707(_get_values)
     4323    0.027    0.000    0.217    0.000 shape_base.py:180(vstack)
    62014    0.295    0.000    0.410    0.000 shape_base.py:61(atleast_2d)
    27380    0.150    0.000    0.206    0.000 validators.py:113(_check_for_invalid_keys)
    27380    0.077    0.000    0.364    0.000 validators.py:129(validate_kwargs)
    27380    0.065    0.000    0.071    0.000 validators.py:31(_check_for_default_values)
     4320    0.010    0.000    0.100    0.000 wlmap.py:334(at)
     4320    0.014    0.000    0.014    0.000 wlmap.py:397(world2image)
     4320    0.077    0.000    0.077    0.000 wlmap.py:481(lookup)
       32    0.000    0.000    0.000    0.000 {_functools.reduce}
        4    0.000    0.000    0.000    0.000 {abs}
     5764    0.006    0.000    0.052    0.000 {any}
    90817    0.048    0.000    0.048    0.000 {built-in method __new__ of type object at 0x1086d1c38}
   122564    0.026    0.000    0.026    0.000 {callable}
     1440   82.020    0.057   82.020    0.057 {gc.collect}
     1440    0.001    0.000    0.001    0.000 {gc.get_referents}
  1188208    0.974    0.000    1.146    0.000 {getattr}
  1490494    0.912    0.000    1.312    0.000 {hasattr}
   305637    0.063    0.000    0.103    0.000 {hash}
 10053222    3.726    0.000    5.157    0.000 {isinstance}
  1561050    0.515    0.000    0.515    0.000 {issubclass}
     8736    0.004    0.000    0.004    0.000 {iter}
2945780/2299880    1.077    0.000    1.626    0.000 {len}
    62143    0.035    0.000    0.035    0.000 {max}
     2908    0.005    0.000    0.035    0.000 {method 'all' of 'numpy.ndarray' objects}
    56312    0.070    0.000    0.543    0.000 {method 'any' of 'numpy.ndarray' objects}
   111020    0.042    0.000    0.042    0.000 {method 'append' of 'list' objects}
        1    0.000    0.000    0.000    0.000 {method 'append' of 'pandas.lib.BlockPlacement' objects}
     4323    0.020    0.000    0.020    0.000 {method 'argsort' of 'numpy.ndarray' objects}
     1452    0.604    0.000    0.604    0.000 {method 'astype' of 'numpy.ndarray' objects}
    41842    0.095    0.000    0.095    0.000 {method 'clear' of 'dict' objects}
       96    0.000    0.000    0.000    0.000 {method 'compress' of 'numpy.ndarray' objects}
     8640    0.010    0.000    0.010    0.000 {method 'conjugate' of 'numpy.generic' objects}
    27380    0.010    0.000    0.010    0.000 {method 'copy' of 'dict' objects}
    85124    3.388    0.000    3.388    0.000 {method 'copy' of 'numpy.ndarray' objects}
        1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}
    40361    0.040    0.000    0.040    0.000 {method 'fill' of 'numpy.ndarray' objects}
     7204    0.020    0.000    0.020    0.000 {method 'format' of 'str' objects}
   145581    0.055    0.000    0.055    0.000 {method 'get' of 'dict' objects}
        4    0.000    0.000    0.000    0.000 {method 'get_indexer' of 'pandas.index.IndexEngine' objects}
   158610    1.100    0.000    1.449    0.000 {method 'get_loc' of 'pandas.index.IndexEngine' objects}
    11552    0.025    0.000    0.135    0.000 {method 'get_value' of 'pandas.index.IndexEngine' objects}
       64    0.000    0.000    0.000    0.000 {method 'item' of 'numpy.ndarray' objects}
    11532    0.008    0.000    0.008    0.000 {method 'items' of 'dict' objects}
    90817    0.031    0.000    0.031    0.000 {method 'iteritems' of 'dict' objects}
     5764    0.002    0.000    0.002    0.000 {method 'itervalues' of 'dict' objects}
     2880    0.012    0.000    0.670    0.000 {method 'max' of 'numpy.ndarray' objects}
     2880    0.012    0.000    0.687    0.000 {method 'min' of 'numpy.ndarray' objects}
     7204    0.167    0.000    0.167    0.000 {method 'nonzero' of 'numpy.ndarray' objects}
   194656    0.039    0.000    0.039    0.000 {method 'pop' of 'dict' objects}
        4    0.027    0.007    0.027    0.007 {method 'randint' of 'mtrand.RandomState' objects}
    76384    0.053    0.000    0.053    0.000 {method 'ravel' of 'numpy.ndarray' objects}
    82500    4.327    0.000    4.327    0.000 {method 'reduce' of 'numpy.ufunc' objects}
     1440    0.009    0.000    0.009    0.000 {method 'reshape' of 'numpy.ndarray' objects}
    47008    0.011    0.000    0.011    0.000 {method 'rstrip' of 'str' objects}
    23048    0.037    0.000    0.037    0.000 {method 'search' of '_sre.SRE_Pattern' objects}
     1445    0.000    0.000    0.000    0.000 {method 'setdefault' of 'dict' objects}
     1440    0.002    0.000    0.002    0.000 {method 'split' of 'str' objects}
    31696    0.023    0.000    0.023    0.000 {method 'startswith' of 'str' objects}
        8    0.000    0.000    0.000    0.000 {method 'std' of 'numpy.ndarray' objects}
    17288    0.030    0.000    2.615    0.000 {method 'sum' of 'numpy.ndarray' objects}
     7212    0.042    0.000    0.042    0.000 {method 'take' of 'numpy.ndarray' objects}
    53344    0.029    0.000    0.029    0.000 {method 'update' of 'dict' objects}
     4328    0.003    0.000    0.003    0.000 {method 'upper' of 'str' objects}
        4    0.000    0.000    0.000    0.000 {method 'values' of 'dict' objects}
   403772    0.317    0.000    0.317    0.000 {method 'view' of 'numpy.ndarray' objects}
      100    0.000    0.000    0.000    0.000 {min}
    80722    0.111    0.000    0.111    0.000 {numpy.core.multiarray.arange}
532222/525014    0.921    0.000    1.055    0.000 {numpy.core.multiarray.array}
   121015    0.481    0.000    0.481    0.000 {numpy.core.multiarray.concatenate}
     2880    0.010    0.000    0.010    0.000 {numpy.core.multiarray.copyto}
     1444    0.042    0.000    0.058    0.000 {numpy.core.multiarray.digitize}
   102330    0.253    0.000    0.253    0.000 {numpy.core.multiarray.empty}
    12964    1.455    0.000    1.455    0.000 {numpy.core.multiarray.putmask}
        4    0.000    0.000    0.000    0.000 {numpy.core.multiarray.result_type}
       89    0.000    0.000    0.000    0.000 {numpy.core.multiarray.zeros}
   778560    0.216    0.000    0.216    0.000 {numpy.core.umath.geterrobj}
   389280    0.303    0.000    0.303    0.000 {numpy.core.umath.seterrobj}
     1464    0.009    0.000    0.009    0.000 {operator.add}
     5760    0.381    0.000    0.381    0.000 {operator.and_}
    34584    0.236    0.000    0.236    0.000 {operator.mul}
     4320    0.023    0.000    0.023    0.000 {operator.neg}
     7200    0.132    0.000    0.132    0.000 {operator.pow}
     7200    0.054    0.000    0.054    0.000 {operator.sub}
    14408    0.116    0.000    0.116    0.000 {operator.truediv}
    43334    0.011    0.000    0.011    0.000 {pandas.algos.ensure_int64}
     7220    0.006    0.000    0.006    0.000 {pandas.algos.ensure_platform_int}
        9    0.000    0.000    0.000    0.000 {pandas.algos.take_1d_int64_int64}
        4    0.020    0.005    0.020    0.005 {pandas.algos.take_2d_axis0_float64_float64}
        4    0.002    0.001    0.002    0.001 {pandas.algos.take_2d_axis0_int64_int64}
        4    0.011    0.003    0.011    0.003 {pandas.algos.take_2d_axis0_object_object}
        4    0.000    0.000    0.000    0.000 {pandas.algos.take_2d_axis1_bool_bool}
     7204    0.283    0.000    0.283    0.000 {pandas.algos.take_2d_axis1_float64_float64}
     7200    0.101    0.000    0.101    0.000 {pandas.algos.take_2d_axis1_int64_int64}
     7200    0.215    0.000    0.215    0.000 {pandas.algos.take_2d_axis1_object_object}
    59101    0.047    0.000    0.047    0.000 {pandas.lib.checknull}
       64    0.000    0.000    0.000    0.000 {pandas.lib.get_blkno_indexers}
    37497    0.425    0.000    0.425    0.000 {pandas.lib.infer_dtype}
    17296    0.005    0.000    0.005    0.000 {pandas.lib.is_bool}
    82184    0.024    0.000    0.024    0.000 {pandas.lib.is_float}
    31716    0.011    0.000    0.011    0.000 {pandas.lib.is_integer}
   211942    0.161    0.000    0.161    0.000 {pandas.lib.isscalar}
    37460    0.341    0.000    0.341    0.000 {pandas.lib.list_to_object_array}
   191886    0.265    0.000    0.382    0.000 {pandas.lib.values_from_object}
      100    0.000    0.000    0.000    0.000 {range}
     1212    0.013    0.000    0.027    0.000 {scipy.integrate._quadpack._qagse}
        1    0.000    0.000    0.000    0.000 {setattr}
     4322    0.045    0.000    0.113    0.000 {sorted}
    11534    0.020    0.000    0.096    0.000 {sum}


MassInference Performance Benchmark


In [2]:
from massinference.angle import Angle
from massinference.catalog import SourceCatalogFactory, FastSampleHaloCatalogFactory, \
    MutableHaloMassCatalog, SourceCatalog, HaloCatalog
from massinference.distribution import MassPrior
from massinference.inference import log_likelihood
from massinference.lenser import MapLenser
from massinference.lightcone import LightconeManager
from massinference.map import KappaMap, ShearMap
from massinference.plot import Limits

import cProfile

ITERATIONS = 4
RADIUS = 2.0

# run parameters
sigma_e = 0.2
random_seed = 1
source_density = 10.0
limits = Limits(Angle.from_degree(1.5), Angle.from_degree(1.4),
                Angle.from_degree(-1.5), Angle.from_degree(-1.4))
limits_with_perimeter = limits.add_perimeter(Angle.from_arcmin(RADIUS))

# make a mock WL catalog, of observed, lensed, galaxy ellipticities:
source_factory = SourceCatalogFactory(limits, source_density, sigma_e)
source_catalog = source_factory.generate()
max_z = source_catalog.dataframe[SourceCatalog.Z].max()

e1, e2 = MapLenser(KappaMap.default(), ShearMap.default()).lens(source_catalog)
base_halo_catalog = MutableHaloMassCatalog.default(limits, max_z)
mass_prior = MassPrior(base_halo_catalog.dataframe[HaloCatalog.HALO_MASS].as_matrix())
halo_catalog_factory = FastSampleHaloCatalogFactory(base_halo_catalog,
                                                    mass_prior, random_seed)
lightcone_manager = LightconeManager(source_catalog, halo_catalog_factory, RADIUS)


def mass_inference_benchmark():
    predictions = lightcone_manager.run(ITERATIONS)
    log_likelihood(predictions, e1, e2, sigma_e)

cProfile.run('mass_inference_benchmark()')


         52642 function calls (52626 primitive calls) in 0.568 seconds

   Ordered by: standard name

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.000    0.000    0.568    0.568 <ipython-input-2-4bb831be9e3f>:36(mass_inference_benchmark)
        1    0.000    0.000    0.568    0.568 <string>:1(<module>)
        8    0.000    0.000    0.000    0.000 _internal.py:227(__init__)
        8    0.000    0.000    0.000    0.000 _internal.py:252(get_data)
        2    0.000    0.000    0.000    0.000 _methods.py:122(_std)
     4328    0.002    0.000    0.017    0.000 _methods.py:31(_sum)
     4320    0.002    0.000    0.018    0.000 _methods.py:37(_any)
        3    0.000    0.000    0.000    0.000 _methods.py:43(_count_reduce_items)
        1    0.000    0.000    0.000    0.000 _methods.py:53(_mean)
        2    0.000    0.000    0.000    0.000 _methods.py:76(_var)
       16    0.000    0.000    0.000    0.000 base.py:1275(<lambda>)
        8    0.000    0.000    0.000    0.000 base.py:1362(__contains__)
        8    0.000    0.000    0.000    0.000 base.py:2074(get_loc)
        4    0.000    0.000    0.000    0.000 base.py:461(__len__)
       16    0.000    0.000    0.000    0.000 base.py:492(values)
       16    0.000    0.000    0.000    0.000 base.py:874(_values)
        4    0.000    0.000    0.002    0.000 catalog.py:165(generate)
        4    0.000    0.000    0.001    0.000 catalog.py:207(set_halo_mass)
        4    0.000    0.000    0.000    0.000 catalog.py:28(__len__)
        4    0.000    0.000    0.000    0.000 catalog.py:42(column_fast)
        8    0.000    0.000    0.000    0.000 common.py:100(is_categorical_dtype)
        8    0.000    0.000    0.000    0.000 common.py:285(is_extension_type)
        4    0.000    0.000    0.000    0.000 common.py:341(_get_dtype_type)
        4    0.000    0.000    0.000    0.000 common.py:438(_apply_if_callable)
        4    0.000    0.000    0.000    0.000 common.py:52(is_object_dtype)
        8    0.000    0.000    0.000    0.000 common.py:57(is_sparse)
        8    0.000    0.000    0.000    0.000 common.py:62(is_categorical)
        8    0.000    0.000    0.000    0.000 common.py:67(is_datetimetz)
        8    0.000    0.000    0.000    0.000 common.py:87(is_datetime64tz_dtype)
        4    0.000    0.000    0.000    0.000 distribution.py:17(sample)
       16    0.000    0.000    0.000    0.000 dtypes.py:74(is_dtype)
        4    0.000    0.000    0.001    0.000 frame.py:2403(__setitem__)
        4    0.000    0.000    0.000    0.000 frame.py:2454(_ensure_valid_index)
        4    0.000    0.000    0.001    0.000 frame.py:2471(_set_item)
        4    0.000    0.000    0.000    0.000 frame.py:2591(_sanitize_column)
        8    0.000    0.000    0.000    0.000 frame.py:769(__len__)
     2880    0.002    0.000    0.002    0.000 fromnumeric.py:1574(shape)
     4328    0.011    0.000    0.032    0.000 fromnumeric.py:1743(sum)
        1    0.000    0.000    0.000    0.000 fromnumeric.py:2843(mean)
        4    0.000    0.000    0.000    0.000 generic.py:1477(_clear_item_cache)
        4    0.000    0.000    0.001    0.000 generic.py:1499(_set_item)
        4    0.000    0.000    0.000    0.000 generic.py:1533(_check_setitem_copy)
       32    0.000    0.000    0.000    0.000 generic.py:7(_check)
        4    0.000    0.000    0.000    0.000 indexing.py:1768(convert_to_index_sliceable)
        1    0.000    0.000    0.000    0.000 inference.py:10(log_likelihood)
        4    0.000    0.000    0.000    0.000 inference.py:98(is_sequence)
        4    0.000    0.000    0.000    0.000 internals.py:1578(should_store)
        4    0.000    0.000    0.000    0.000 internals.py:2765(shape)
       12    0.000    0.000    0.000    0.000 internals.py:2767(<genexpr>)
        4    0.000    0.000    0.000    0.000 internals.py:2769(ndim)
        8    0.000    0.000    0.000    0.000 internals.py:2841(_get_items)
        4    0.000    0.000    0.000    0.000 internals.py:298(dtype)
        4    0.000    0.000    0.000    0.000 internals.py:330(set)
        4    0.000    0.000    0.000    0.000 internals.py:3613(set)
        4    0.000    0.000    0.000    0.000 internals.py:3637(value_getitem)
        8    0.000    0.000    0.000    0.000 internals.py:4640(_get_blkno_placements)
     1440    0.095    0.000    0.229    0.000 lensing.py:12(bmo_f)
     1440    0.096    0.000    0.215    0.000 lensing.py:36(bmo_g)
     2880    0.046    0.000    0.046    0.000 lensing.py:50(l_f)
        4    0.000    0.000    0.000    0.000 lensing.py:54(delta_c)
     2880    0.167    0.000    0.199    0.000 lensing.py:58(f_f)
     1440    0.082    0.000    0.557    0.000 lightcone.py:36(compute_shear)
        1    0.008    0.008    0.567    0.567 lightcone.py:78(run)
     2880    0.004    0.000    0.015    0.000 numeric.py:148(ones)
        4    0.000    0.000    0.000    0.000 numeric.py:414(asarray)
        9    0.000    0.000    0.000    0.000 numeric.py:484(asanyarray)
       20    0.000    0.000    0.000    0.000 range.py:455(__len__)
        4    0.000    0.000    0.000    0.000 series.py:2789(_sanitize_index)
        4    0.000    0.000    0.000    0.000 shape_base.py:61(atleast_2d)
        4    0.000    0.000    0.000    0.000 {callable}
       32    0.000    0.000    0.000    0.000 {getattr}
       21    0.000    0.000    0.000    0.000 {hasattr}
        8    0.000    0.000    0.000    0.000 {hash}
     4462    0.003    0.000    0.003    0.000 {isinstance}
       13    0.000    0.000    0.000    0.000 {issubclass}
        4    0.000    0.000    0.000    0.000 {iter}
    76/60    0.000    0.000    0.000    0.000 {len}
       22    0.000    0.000    0.000    0.000 {max}
     4320    0.003    0.000    0.022    0.000 {method 'any' of 'numpy.ndarray' objects}
        4    0.000    0.000    0.000    0.000 {method 'append' of 'list' objects}
        4    0.000    0.000    0.000    0.000 {method 'clear' of 'dict' objects}
        8    0.000    0.000    0.000    0.000 {method 'copy' of 'numpy.ndarray' objects}
        1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}
        8    0.000    0.000    0.000    0.000 {method 'get_loc' of 'pandas.index.IndexEngine' objects}
        4    0.000    0.000    0.000    0.000 {method 'permutation' of 'mtrand.RandomState' objects}
     8653    0.031    0.000    0.031    0.000 {method 'reduce' of 'numpy.ufunc' objects}
        2    0.000    0.000    0.000    0.000 {method 'std' of 'numpy.ndarray' objects}
       16    0.000    0.000    0.000    0.000 {method 'view' of 'numpy.ndarray' objects}
       13    0.000    0.000    0.000    0.000 {numpy.core.multiarray.array}
     2880    0.007    0.000    0.007    0.000 {numpy.core.multiarray.copyto}
     2880    0.004    0.000    0.004    0.000 {numpy.core.multiarray.empty}
        2    0.000    0.000    0.000    0.000 {numpy.core.multiarray.zeros}
        4    0.000    0.000    0.000    0.000 {pandas.algos.ensure_int64}
        4    0.000    0.000    0.000    0.000 {pandas.lib.get_blkno_indexers}
        8    0.000    0.000    0.000    0.000 {pandas.lib.values_from_object}
        3    0.000    0.000    0.000    0.000 {range}


Conclusions

  • MassInference outperforms Pangloss by 290x
  • Only drilling once and removing duplication at the lightcone level has led to a big performance boost, as expected
  • MassInference spends ~80% of time in lensing code (lensing.bmo_f, lensing.bmo_g)
    • This code performs a long sequence of numerical operations on large arrays, would be prime for GPU acceleration
    • We could also try bin-caching
  • The iterative part of the calculation is embarassingly parallel and should scale linearly over cluster
    • mpi4py
  • Pangloss spends lots of time garbage collecting
    • If this pops up in MassInference we can look into making an objectpool, resuing objects etc

In [ ]: