Files
Home-AssistantConfig/deps/sqlalchemy/testing/__pycache__/profiling.cpython-34.pyc

80 lines
7.6 KiB
Plaintext
Raw Normal View History

2016-10-11 16:42:06 +00:00
<EFBFBD>
}<7D><>W<EFBFBD> <00> @s<>dZddlZddlZddlmZddlmZddlZddlZddl Z yddl
Z
Wne k
r<>dZ
YnXddlm Z m Z mZmZdZdZGdd <00>d e<00>Zd
d d <00>Ze jd
d d<00><00>ZdS)z<>Profiling 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.
<EFBFBD>N<>)<01>
gc_collect)<01>config<69>)<04>jython<6F>pypy<70>win32<33>update_wrapperc@s|eZdZdZdd<00>Zedd<00><00>Zdd<00>Zdd <00>Zd
d <00>Z d d <00>Z
dd<00>Z dd<00>Z dS)<13>ProfileStatsFilez<65>"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
cCs<>tjdk otjj|_|jp?tjdk o?tjj|_tjj|<00>|_ tjj
|j <00>d|_ t j dd<00><00>|_|j<00>|jr<>|j<00>ndS)NrcSs tjt<00>S)N)<03> collections<6E> defaultdict<63>dict<63>rr<00>B/tmp/pip-build-zkr322cu/sqlalchemy/sqlalchemy/testing/profiling.py<70><lambda>7sz+ProfileStatsFile.__init__.<locals>.<lambda><3E><><EFBFBD><EFBFBD><EFBFBD>)r<00>optionsZforce_write_profiles<65> force_writeZwrite_profiles<65>write<74>os<6F>path<74>abspath<74>fname<6D>split<69> short_fnamer r <00>data<74>_read<61>_write)<02>self<6C>filenamerrr<00>__init__+s 
 zProfileStatsFile.__init__cCs<>tjjdtjj}djdd<00>tjdd<00>D<><00>}|g}|j|<00>tro|jd<00>nt r<>|jd<00>nt
r<>|jd <00>n|jtjj j r<>d
nd <00>tj j<00>}|j|r<>d p<>d <00>dj|<00>S)N<>_<>.cSsg|]}t|<00><00>qSr)<01>str)<02>.0<EFBFBD>vrrr<00>
<listcomp>Ds z1ProfileStatsFile.platform_key.<locals>.<listcomp>rrrr<00>winZ nativeunicodeZ dbapiunicodeZ cextensionsZ nocextensions)r<00>db<64>nameZdriver<65>join<69>sys<79> version_info<66>appendrrr<00>dialectZconvert_unicode<64> requirementsZ_has_cextensions)rZ dbapi_key<65>
py_versionZplatform_tokensZ _has_cextrrr<00> platform_key>s )  zProfileStatsFile.platform_keycCs)t}||jko(|j|j|kS)N)<03> _current_testrr1)r<00>test_keyrrr<00> has_statsWszProfileStatsFile.has_statsc Cs<>t}|j|}||j}d|kr=g|d<}n
|d}d|krdd|d<}n
|d}t|<00>|k}|s<>|j|<00>|jr<>|j<00>nd}n|d||f}|dd7<|S)N<>counts<74> current_countr<00>linenor)r2rr1<00>lenr-rr) r<00> callcountr3<00>per_fn<66> per_platformr5r6Z has_count<6E>resultrrrr<^s$   
 
    zProfileStatsFile.resultcCs{t}|j|}||j}|d}|d}|t|<00>krW|||d<n
||d<|jrw|j<00>ndS)Nr5r6rr)r2rr1r8rr)rr9r3r:r;r5r6rrr<00>replaceys  


 zProfileStatsFile.replacecCs d|jS)Na # %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)rrrr<00>_header<65>szProfileStatsFile._headerc
Cs<>yt|j<00>}Wntk
r+dSYnXx<58>t|<00>D]<5D>\}}|j<00>}| s9|jd<00>rmq9n|j<00>\}}}|j|}||}dd<00>|jd<00>D<>} | |d<|d|d<d|d <q9W|j<00>dS)
N<EFBFBD>#cSsg|]}t|<00><00>qSr)<01>int)r$<00>countrrrr&<00>s z*ProfileStatsFile._read.<locals>.<listcomp><3E>,r5rr7rr6) <09>openr<00>IOError<6F> enumerate<74>strip<69>
startswithrr<00>close)
r<00> profile_fr7<00>liner3r1r5r:r;<00>crrrr<00>s     

zProfileStatsFile._readcCs<>td|j<16>t|jd<00>}|j|j<00><00>x<>t|j<00>D]}|j|}|jd|<16>xXt|<00>D]J}||}djdd<00>|dD<><00>}|jd|||f<16>qwWqFW|j<00>dS) NzWriting profile file %s<>wz
# TEST: %s
rBcss|]}t|<00>VqdS)N)r#)r$rArrr<00> <genexpr><3E>sz*ProfileStatsFile._write.<locals>.<genexpr>r5z %s %s %s
) <09>printrrCrr><00>sortedrr*rH)rrIr3r:r1r;rKrrrr<00>s 
 "zProfileStatsFile._writeN) <0A>__name__<5F>
__module__<EFBFBD> __qualname__<5F>__doc__r <00>propertyr1r4r<r=r>rrrrrrr
#s      r
g<><67><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?cs<00>fdd<00>}|S)a<>Assert 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.
cs"<00><00>fdd<00>}t|<00><00>S)Nc
s'td<00><00><01><01>||<00>SWdQXdS)N<>variance)<01>count_functions)<02>args<67>kw)<02>fnrUrr<00>wrap<61>sz3function_call_count.<locals>.decorate.<locals>.wrap)r )rYrZ)rU)rYr<00>decorate<74>sz%function_call_count.<locals>.decorater)rUr[r)rUr<00>function_call_count<6E>s r\c csrtdkrtd<00><00>ntj<00> rItj rItjdtj<16>nt<00>tj <00>}|j
<00>dV|j <00>t j |dtj<00>}|j}tj|<00>}|dkr<>d}n |\}}td||f<16>|jd<00>|j<00>|rnt||<14>}t||<18>|k}|s,tjrntjrEtj|<00>qktd||d|tjf<16><00>qnndS)NzcProfile is not installedz<64>No profiling stats available on this platform for this function. Run tests with --write-profiles to add statistics to %s for this platform.<2E>streamzPstats calls: %d Expected %sZ
cumulativez<EFBFBD>Adjusted function call count %s not within %s%% of expected %s, platform %s. Rerun with --write-profiles to regenerate this callcount.<2E>d)<1B>cProfileZSkipTest<73>_profile_statsr4rrZ skip_testrrZProfile<6C>enable<6C>disable<6C>pstatsZStatsr+<00>stdoutZ total_callsr<rNZ
sort_statsZ print_statsr@<00>absrr=<00>AssertionErrorr1) rU<00>pr<70>statsr9<00>expectedZexpected_countZline_noZdeviance<63>failedrrrrV<00>s@  

      
 
rV)rSrr+<00>utilr<00>rrcr <00>
contextlibr_<00> ImportErrorrrrr r2r`<00>objectr
r\<00>contextmanagerrVrrrr<00><module> s$       "<16>