• File: prof.cpython-37.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/opt/alt/python37/lib/python3.7/site-packages/nose/plugins/__pycache__/prof.cpython-37.pyc
  • Date Modified: 07/07/2021 11:30 PM
  • File size: 4.31 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit
B

fP@sdZyddlZddlmZWnek
r8d\ZZYnXddlZddlZddlZddlZddlm	Z	ddl
mZedZ
Gdd	d	e	ZdS)
a/This plugin will run tests using the hotshot profiler, which is part
of the standard library. To turn it on, use the ``--with-profile`` option
or set the NOSE_WITH_PROFILE environment variable. Profiler output can be
controlled with the ``--profile-sort`` and ``--profile-restrict`` options,
and the profiler output file may be changed with ``--profile-stats-file``.

See the `hotshot documentation`_ in the standard library documentation for
more details on the various output options.

.. _hotshot documentation: http://docs.python.org/library/hotshot.html
N)stats)NN)Plugin)tolistznose.pluginsc@s`eZdZdZdZdZddZddZeeZdd	Z	d
dZ
dd
ZddZddZ
ddZdS)ProfilezC
    Use this plugin to run tests using the hotshot profiler. 
    NFcCst|sdSt||||jddd|ddddd	|jd
ddd|d
dd|jdddd|ddddS)z&Register commandline options.
        Nz--profile-sortZstoreprofile_sortZNOSE_PROFILE_SORTZ
cumulativeZSORTz"Set sort order for profiler output)actiondestdefaultmetavarhelpz--profile-stats-fileprofile_stats_fileFILEZNOSE_PROFILE_STATS_FILEz;Profiler stats file; default is a new temp file on each run)rrr
r	rz--profile-restrictappendprofile_restrictZRESTRICTZNOSE_PROFILE_RESTRICTz?Restrict profiler output. See help for pstats.Stats for details)	availableroptionsZ
add_optionget)selfparserenvrB/opt/alt/python37/lib/python3.7/site-packages/nose/plugins/prof.pyr!s"

zProfile.optionscCstdk	S)N)hotshot)clsrrrr8szProfile.availablecCs&|sdS|t|j|_dS)z5Create profile stats file and load profiler.
        N)r
_create_pfilerrpfileprof)rrrrbegin<sz
Profile.begincCsf|sd|_dSt|||||_|jr<|j|_d|_nd|_d|_d|_|j	|_
t|j|_
dS)zConfigure plugin.
        FNT)rZenabledr	configureconfrrclean_stats_filefilenorsortrrrestrict)rrrrrrrDszProfile.configurecs2sdStd|j|ffdd	}|S)z6Wrap entire test run in :func:`prof.runcall`.
        Nzpreparing test %scs|||dS)N)rZruncall)resultrtest)rrrrun_and_profile\sz,Profile.prepareTest.<locals>.run_and_profile)rlogdebugr)rr%r&r)rrprepareTestVs
zProfile.prepareTestcCstd|jt|j}||jt	|d}|rH|j
}||_
ntj}|t_z.|j
rxtd|j
|j|j
n|Wd|r||_
n|t_XdS)z Output profiler report.
        zprinting profiler reportstreamz"setting profiler restriction to %sN)r'r(rcloserloadrZ
sort_statsr"hasattrr*sysstdoutr#Zprint_stats)rr*Z
prof_statsZ	compat_25Ztmprrrreportas$


zProfile.reportcCs|sdSy|jWntk
r.YnX|jr|jrbyt|jWntk
r`YnXyt|j	Wntk
rYnXdS)z5Clean up stats file, if configured to do so.
        N)
rrr+AttributeErrorr r!osOSErrorunlinkr)rr$rrrfinalizes"zProfile.finalizecCs |jst\|_|_d|_dS)NT)rtempfileZmkstempr!r )rrrrrszProfile._create_pfile)__name__
__module____qualname____doc__rr rrclassmethodrrr)r0r5rrrrrrsr)r:rrImportErrorZloggingr2r.r6Znose.plugins.baserZ	nose.utilrZ	getLoggerr'rrrrr<module>s