File: //opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/testing/profiling.pyc
�
���ec @ s
d Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l m Z d d l
m Z d d l
m Z y d d l
Z
Wn e k
r� d Z
n Xd Z d a d � Z d e f d
� � YZ d d d d
� Z e j d d � � Z d S( s� 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.
i����Ni ( t config( t
gc_collecti ( t has_compiled_extc C s | a t j r t j � n d S( N( t
_current_testt _profile_statst force_writet reset_count( t id_( ( sM /opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/testing/profiling.pyt _start_current_test2 s t ProfileStatsFilec B sk e Z d Z d d d � Z e d � � Z d � Z d � Z d � Z d � Z
d � Z d � Z d
� Z
RS( s� Store per-platform/fn profiling results in a file.
There was no json module available when this was written, but now
the file format which is very deterministically line oriented is kind of
handy in any case for diffs and merges.
t
cumulativec C s� t j d k o t j j | _ | j p? t j d k o? t j j | _ t j j | � | _
t j j | j
� d | _ t
j d � � | _ | | _ | | _ | j � | j r� | j � n d S( Ni����c S s
t j t � S( N( t collectionst defaultdictt dict( ( ( sM /opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/testing/profiling.pyt <lambda>M t ( R t optionst Nonet force_write_profilesR t write_profilest writet ost patht abspatht fnamet splitt short_fnameR R t datat dumpt sortt _readt _write( t selft filenameR R ( ( sM /opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/testing/profiling.pyt __init__C s
c C s
t j j d t j j } t j j d k rT t j j j t j j � rT | d 7} n d j g t j d d !D] } t
| � ^ qk � } t j � t j
� j � t j � j � | | g } | j t j j j r� d n d � t � } | j | r� d p� d
� d j | � S( Nt _t sqlitet _filet .i i t
nativeunicodet dbapiunicodet cextensionst
nocextensions( R t dbt namet drivert dialectt _is_url_file_dbt urlt joint syst version_infot strt platformt machinet systemt lowert python_implementationt appendt convert_unicodeR ( R t dbapi_keyt vt
py_versiont platform_tokenst _has_cext( ( sM /opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/testing/profiling.pyt platform_keyW s
2 c C s) t } | | j k o( | j | j | k S( N( R R RA ( R t test_key( ( sM /opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/testing/profiling.pyt has_statsu s c C s� t } | j | } | | j } d | k r= g | d <} n
| d } d | k rd d | d <} n
| d } t | � | k } | s� | j | � | j r� | j � n d } n | d | | f } | d c d 7<| S( Nt countst
current_counti t linenoi ( R R RA t lenR: R R R ( R t callcountRB t per_fnt per_platformRD RE t has_countt result( ( sM /opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/testing/profiling.pyRL { s$
c C sd t } | | j k r d S| j | } | j | k r9 d S| | j } d | k r` g | d (n d S( NRD ( R R RA ( R RB RI RJ ( ( sM /opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/testing/profiling.pyR � s
c C s{ t } | j | } | | j } | d } | d } | t | � k rW | | | d <n
| | d <| j rw | j � n d S( NRD RE i i����( R R RA RG R R ( R RH RB RI RJ RD RE ( ( sM /opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/testing/profiling.pyt replace� s
c C s d | j S( 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 ( ( sM /opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/testing/profiling.pyt _header� s c C s� y t | j � } Wn t k
r'