Project:Portage/Profiling
From Gentoo Wiki
Jump to:navigation
Jump to:search
Collecting profiles
To collect a pstats profile in outfile
:
user $
python -m cProfile -o outfile /usr/bin/emerge <args>
Examining profiles
Assuming the profile was collected above in outfile
, examine it:
user $
python
>>> import pstats >>> p = pstats.Stats('outfile') >>> p.print_stats()
Check out the https://docs.python.org/3/library/profile.html for more details.
Example
This example is from:
user $
python -m cProfile -o portage.cprof /usr/bin/emerge -pe @world
user $
python
>>> import pstats >>> p = pstats.Stats('portage.cprof') >>> p.sort_stats('time').print_stats(20) Thu Feb 11 05:41:32 2021 portage.cprof 34119136 function calls (32523207 primitive calls) in 94.908 seconds Ordered by: internal time List reduced from 3287 to 20 due to restriction <20> ncalls tottime percall cumtime percall filename:lineno(function) 386794 6.291 0.000 8.858 0.000 /usr/lib/python3.9/site-packages/portage/util/digraph.py:163(child_nodes) 1515214/2431 5.836 0.000 17.283 0.007 /usr/lib/python3.9/site-packages/_emerge/depgraph.py:7838(gather_deps) 119338/96762 5.014 0.000 15.934 0.000 /usr/lib/python3.9/site-packages/portage/dep/__init__.py:1243(__init__) 1865 4.142 0.002 8.434 0.005 /usr/lib/python3.9/site-packages/portage/package/ebuild/config.py:2250(regenerate) 431910 3.566 0.000 3.566 0.000 {method 'match' of 're.Pattern' objects} 132060 3.070 0.000 5.127 0.000 /usr/lib/python3.9/site-packages/portage/versions.py:363(__init__) 3726 2.841 0.001 18.456 0.005 /usr/lib/python3.9/site-packages/portage/package/ebuild/config.py:1432(setcpv) 3140510 1.928 0.000 1.928 0.000 /usr/lib/python3.9/site-packages/_emerge/Task.py:23(__hash__) 2685578 1.699 0.000 1.875 0.000 {method 'add' of 'set' objects} 22576 1.650 0.000 2.502 0.000 /usr/lib/python3.9/site-packages/portage/dep/__init__.py:873(__init__) 1564306 1.559 0.000 1.559 0.000 /usr/lib/python3.9/site-packages/_emerge/DepPrioritySatisfiedRange.py:43(_ignore_runtime_post) 444155 1.429 0.000 1.429 0.000 {method 'split' of 'str' objects} 3920 1.403 0.000 2.001 0.001 /usr/lib/python3.9/site-packages/_emerge/resolver/output.py:142(map_to_use_expand) 141972 1.148 0.000 1.801 0.000 /usr/lib/python3.9/site-packages/portage/package/ebuild/config.py:2637(_getitem) 13373 1.126 0.000 14.950 0.001 /usr/lib/python3.9/site-packages/portage/dep/__init__.py:402(_use_reduce_cached) 2823 1.022 0.000 1.412 0.001 /usr/lib/python3.9/site-packages/portage/package/ebuild/_config/LicenseManager.py:161(getMissingLicenses) 1597513 1.006 0.000 1.150 0.000 {method 'get' of 'dict' objects} 829430/823631 0.934 0.000 1.514 0.000 {built-in method builtins.getattr} 1573917 0.886 0.000 0.886 0.000 {method 'group' of 're.Match' objects} 63283 0.864 0.000 1.593 0.000 /usr/lib/python3.9/site-packages/portage/dep/__init__.py:2148(match_from_list) <pstats.Stats object at 0x7fa392065c10>