<div dir="ltr">One trick is the following (example using the Abacus activity):<div><br></div><div>* In sugar, start one activity</div><div>* without close the activity, go tot the terminal, and see the command line used to run it</div>
<div>$ ps ax | grep Abacus<br clear="all"><div>2250 ? Sl 0:10 python2 /usr/bin/sugar-activity AbacusActivity.AbacusActivity -b org.sugarlabs.AbacusActivity -a ff8dc731a329b184b7d28c40cc85c47ff2e433cb -o 7ae05000-b61c-4fd8-9b66-e5125f3ba81f > abacus_profile.log<br>
</div><div><br></div><div>* close the activity you want profile.</div><div>* in the terminal do:</div><div>$ cd Activities/Abacus.activity</div><div>$ python2 <b>-m cProfile </b>/usr/bin/sugar-activity AbacusActivity.AbacusActivity -b org.sugarlabs.AbacusActivity -a ff8dc731a329b184b7d28c40cc85c47ff2e433cb -o 7ae05000-b61c-4fd8-9b66-e5125f3ba81f <b>> abacus_profile.log</b></div>
<div><br></div><div>Adding -m cProfile to get the profile information, and redirecting to a file</div><div>The activity will start, in this case, some of the icons are not displayed.</div><div>Close the activity and check the generated file, in this case abacus_profile.log</div>
<div><br></div><div>The content of the file is attached, have columns like:</div><div><br></div><div><div> ncalls tottime percall cumtime percall filename:lineno(function)</div><div> 1 0.002 0.002 0.002 0.002 <string>:1(<module>)</div>
<div><br></div><div>Explanation about what means every column is here:</div><div><br></div><div><a href="https://docs.python.org/2/library/profile.html#instant-user-s-manual">https://docs.python.org/2/library/profile.html#instant-user-s-manual</a><br>
</div><div><br></div></div><div>Sorting by the second column (tottime) , and filtering the top 20 we can see:</div><div><br></div><div><div><font face="courier new, monospace">[gonzalo@localhost sugar]$ sort -nr -k2 /run/media/gonzalo/0824-E6BD/abacus_profile.log | head -20</font></div>
<div><font face="courier new, monospace"> 1 2.879 2.879 5.105 5.105 activity.py:375(run_main_loop)</font></div><div><font face="courier new, monospace"> 504 1.177 0.002 1.212 0.002 abacus_window.py:108(_svg_str_to_pixbuf)</font></div>
<div><font face="courier new, monospace"> 30 0.696 0.023 1.392 0.046 abacus_window.py:329(update)</font></div><div><font face="courier new, monospace"> 420 0.559 0.001 1.289 0.003 sprites.py:312(draw)</font></div>
<div><font face="courier new, monospace"> 448 0.433 0.001 0.786 0.002 sprites.py:120(remove_from_list)</font></div><div><font face="courier new, monospace">5642/5394 0.387 0.000 0.666 0.000 module.py:252(__getattr__)</font></div>
<div><font face="courier new, monospace"> 1156 0.359 0.000 0.359 0.000 {method 'remove' of 'list' objects}</font></div><div><font face="courier new, monospace"> 309 0.236 0.001 1.142 0.004 sprites.py:232(set_layer)</font></div>
<div><font face="courier new, monospace"> 1 0.221 0.221 0.512 0.512 activity.py:231(__init__)</font></div><div><font face="courier new, monospace"> 363 0.207 0.001 0.455 0.001 sprites.py:347(draw_label)</font></div>
<div><font face="courier new, monospace"> 20 0.198 0.010 0.198 0.010 {method 'paint' of 'cairo.Context' objects}</font></div><div><font face="courier new, monospace"> 420 0.145 0.000 0.145 0.000 {method 'fill' of 'cairo.Context' objects}</font></div>
<div><font face="courier new, monospace"> 63 0.143 0.002 0.143 0.002 {method 'write' of 'file' objects}</font></div><div><font face="courier new, monospace"> 18935 0.143 0.000 0.202 0.000 sprites.py:96(get_sprite)</font></div>
<div><font face="courier new, monospace">12193/11504 0.127 0.000 0.354 0.000 {getattr}</font></div><div><font face="courier new, monospace">27982/27779 0.117 0.000 0.118 0.000 {len}</font></div><div>
<font face="courier new, monospace"> 1 0.115 0.115 5.313 5.313 AbacusActivity.py:72(__init__)</font></div><div><font face="courier new, monospace"> 31 0.099 0.003 0.099 0.003 {method 'send_message_with_reply_and_block' of '_dbus_bindings.Connection' objects}</font></div>
<div><font face="courier new, monospace"> 10858 0.098 0.000 0.098 0.000 {method 'append' of 'list' objects}</font></div><div><font face="courier new, monospace"> 43 0.088 0.002 0.253 0.006 icon.py:133(_get_icon_info)</font></div>
</div><div><br></div>-- <br><div dir="ltr">Gonzalo Odiard<br><br><div>SugarLabs - Software for children learning <br></div></div>
</div></div>