• File: profiling.pyo
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/profiling.pyo
  • Date Modified: 08/05/2019 10:14 AM
  • File size: 8.56 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit

4]c@sdZddlZddlZddlZddlZddlZddlmZddlm	Z	ddlm
Z
ddlmZdd	lmZdd
lm
Z
yddlZWnek
rdZnXdZdZdefdYZd
dZejd
dZdS(sProfiling support for unit and performance tests.

These are special purpose profiling methods which operate
in a more fine-grained way than nose's profiling plugin.

iNi(tconfig(t
gc_collecti(tjython(tpypy(tupdate_wrapper(twin32tProfileStatsFilecBs\eZdZdZedZdZdZdZdZ	dZ
dZRS(	s"Store per-platform/fn profiling results in a file.

    We're still targeting Py2.5, 2.4 on 0.7 with no dependencies,
    so no json lib :(  need to roll something silly

    cCstjdk	otjj|_|jp?tjdk	o?tjj|_tjj	||_
tjj|j
d|_t
jd|_|j|jr|jndS(NicSs
tjtS(N(tcollectionstdefaultdicttdict(((sO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/profiling.pyt<lambda>:t(RtoptionstNonetforce_write_profilestforce_writetwrite_profilestwritetostpathtabspathtfnametsplittshort_fnameRRtdatat_readt_write(tselftfilename((sO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/profiling.pyt__init__0s	
	cCstjjdtjj}djgtjdd!D]}t|^q1}|g}|j|t	rx|jdnt
r|jdntr|jdn|jtjjj
rdnd	tjj}|j|rd
pddj|S(Nt_t.iiRRtwint
nativeunicodetdbapiunicodetcextensionst
nocextensions(Rtdbtnametdrivertjointsystversion_infotstrtappendRRRtdialecttconvert_unicodetrequirementst_has_cextensions(Rt	dbapi_keytvt
py_versiontplatform_tokenst	_has_cext((sO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/profiling.pytplatform_keyBs 2	
cCs)t}||jko(|j|j|kS(N(t
_current_testRR6(Rttest_key((sO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/profiling.pyt	has_stats[sc	Cst}|j|}||j}d|kr=g|d<}n
|d}d|krdd|d<}n
|d}t||k}|s|j||jr|jnd}n|d||f}|dcd7<|S(Ntcountst
current_countitlinenoi(R7RR6tlenR,RRR
(	Rt	callcountR8tper_fntper_platformR:R;t	has_counttresult((sO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/profiling.pyRBas$




	
	cCs{t}|j|}||j}|d}|d}|t|krW|||d<n
||d<|jrw|jndS(NR:R;ii(R7RR6R=RR(RR>R8R?R@R:R;((sO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/profiling.pytreplace|s




	cCsd|jS(Ns
# %s
# This file is written out on a per-environment basis.
# For each test in aaa_profiling, the corresponding function and 
# environment is located within this file.  If it doesn't exist,
# the test is skipped.
# If a callcount does exist, it is compared to what we received. 
# assertions are raised if the counts do not match.
# 
# To add a new callcount test, apply the function_call_count 
# decorator and re-run the tests using the --write-profiles 
# option - this file will be rewritten including the new count.
# 
(R(R((sO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/profiling.pyt_headerscCsyt|j}Wntk
r'dSXxt|D]\}}|j}|s5|jdriq5n|j\}}}|j|}||}g|jdD]}	t|	^q}
|
|d<|d|d<d|d<q5W|j	dS(Nt#t,R:iR<iR;(
topenRtIOErrort	enumeratetstript
startswithRRtinttclose(Rt	profile_fR<tlineR8R6R:R?R@tcounttc((sO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/profiling.pyRs 


(
cCsd|jGHt|jd}|j|jxt|jD]|}|j|}|jd|xUt|D]G}||}djd|dD}|jd|||fqrWqAW|jdS(NsWriting profile file %stws

# TEST: %s

RFcss|]}t|VqdS(N(R+(t.0RP((sO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/profiling.pys	<genexpr>sR:s	%s %s %s
(RRGRRDtsortedRR(RM(RRNR8R?R6R@RQ((sO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/profiling.pyRs

"(t__name__t
__module__t__doc__RtpropertyR6R9RBRCRDRR(((sO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/profiling.pyR(s				
		g?csfd}|S(sAssert a target for a test case's function call count.

    The main purpose of this assertion is to detect changes in
    callcounts for various functions - the actual number is not as important.
    Callcounts are stored in a file keyed to Python version and OS platform
    information.  This file is generated automatically for new tests,
    and versioned so that unexpected changes in callcounts will be detected.

    csfd}t|S(Ncs'td||SWdQXdS(Ntvariance(tcount_functions(targstkw(tfnRY(sO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/profiling.pytwraps(R(R]R^(RY(R]sO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/profiling.pytdecorates((RYR_((RYsO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/profiling.pytfunction_call_countsc	csptdkrtjdntjrLtjrLtjdtjnt	tj
}|jdV|jt
j|dtj}|j}tj|}|dkrd}n|\}}d||fGH|jd|j|rlt||}t|||k}|s*tjrltjrCtj|qitd||d|tjfqlndS(NscProfile is not installedsNo profiling stats available on this platform for this function.  Run tests with --write-profiles to add statistics to %s for this platform.tstreamsPstats calls: %d Expected %st
cumulativesAdjusted function call count %s not within %s%% of expected %s, platform %s. Rerun with --write-profiles to regenerate this callcount.id(tcProfileR
Rt_skip_test_exceptiont_profile_statsR9Rt	skip_testRRtProfiletenabletdisabletpstatstStatsR)tstdoutttotal_callsRBt
sort_statstprint_statsRLtabsRRCtAssertionErrorR6(	RYtprtstatsR>texpectedtexpected_counttline_notdeviancetfailed((sO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/profiling.pyRZs@

		

	(RWRt
contextlibRRjR)RRtutilRRRRRRctImportErrorR
R7RetobjectRR`tcontextmanagerRZ(((sO/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/testing/profiling.pyt<module>
s*