Ñò ‡„[Jc@sºdZddkZddkZddklZddkZdZeƒZheƒd6e d6dd 6dd 6Z da dd „Z dhdd„Zd„Zd„Zd„Zd„ZdS(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ÿÿÿÿN(tfunction_namedtprofiledtfunction_call_counttconditional_call_countttargetstreportttimetcallstsorttlimitc saˆdjo d‰nˆtjo dˆGHntiˆƒdˆ‰‡‡‡fd†}|S(s7Optional function profiling. @profiled('label') or @profiled('label', report=True, sort=('calls',), limit=20) Enables profiling for a function when 'label' is targetted for profiling. Report options can be supplied, and override the global configuration and command-line options. tanonymous_targets'Warning: redefining profile target '%s's%s.profcs(‡‡‡‡fd†}t|ˆiƒS(Nc söˆtdjo"ˆiddƒ oˆ||ŽStˆˆ||Ž\}}}ˆidtdƒ}|owˆidtdƒ}ˆidtdƒ}dˆˆfGH|ƒ}|i|Œ|o|i|ƒqå|iƒntiˆƒ|S(NRtalwaysRRR s#Profile report for target '%s' (%s)(tprofile_configtgettNonet_profilet sort_statst print_statstostunlink( targstkwtelapsedt load_statstresultRtsort_R tstats(ttargett target_optstfilenametfn(s=/usr/lib/python2.6/site-packages/sqlalchemy/test/profiling.pyR+s$    (Rt__name__(RR(RRR(Rs=/usr/lib/python2.6/site-packages/sqlalchemy/test/profiling.pyt decorator*sN(Rt all_targetstadd(RRR ((RRRs=/usr/lib/python2.6/site-packages/sqlalchemy/test/profiling.pyRs      gš™™™™™©?c sÕttiƒ}dig}tiD]}|t|ƒq#~ƒ‰xb|oZdig}|D]}|t|ƒq]~ƒ}||jo||‰Pn|iƒqEWˆdjod„S‡‡‡fd†}|S(sãAssert a target for a test case's function call count. count Optional, general target function call count. versions Optional, a dictionary of Python version strings to counts, for example:: { '2.5.1': 110, '2.5': 100, '2.4': 150 } The best match for the current running python will be used. If none match, 'count' will be used as the fallback. variance An +/- deviation percentage, defaults to 5%. t.cSs|S(((R((s=/usr/lib/python2.6/site-packages/sqlalchemy/test/profiling.pythscs(‡‡‡‡fd†}t|ˆiƒS(Nc sázµdˆi}t|ˆ||Ž\}}}|ƒ}|i}|iddƒ|iƒtˆˆƒ}|ˆ|jp|ˆ|jo$td|ˆdˆˆfƒ‚n|SWdtii |ƒoti |ƒnXdS(Ns%s.profRt cumulativesJFunction call count %s not within %s%% of expected %s. (Python version %s)id( RRt total_callsRRtinttAssertionErrorRtpathtexistsR( RRRRt stat_loaderRRRtdeviance(tcounttvariancet py_versionR(s=/usr/lib/python2.6/site-packages/sqlalchemy/test/profiling.pytcountedks"    (RR(RR0(R-R.R/(Rs=/usr/lib/python2.6/site-packages/sqlalchemy/test/profiling.pyR jsN(tlisttsyst version_infotjointstrtpopR( R-tversionsR.R3t_[1]tvt_[2]tversionR ((R-R.R/s=/usr/lib/python2.6/site-packages/sqlalchemy/test/profiling.pyRFs30   cs‡‡fd†}|S(sbApply a function call count conditionally at runtime. Takes two arguments, a callable that returns a key value, and a dict mapping key values to a tuple of arguments to function_call_count. The callable is not evaluated until the decorated function is actually invoked. If the `discriminator` returns a key not present in the `categories` dictionary, no call count assertion is applied. Useful for integration tests, where running a named test in isolation may have a function count penalty not seen in the full suite, due to lazy initialization in the DB-API, SA, etc. cs%‡‡‡fd†}t|ˆiƒS(NcsOˆiˆƒdƒ}|djoˆ||ŽSt|Œˆƒ}|||ŽS(N(R RR(RRtcriteriat rewrapped(Rt discriminatort categories(s=/usr/lib/python2.6/site-packages/sqlalchemy/test/profiling.pyt at_runtime—s  (RR(RR@(R>R?(Rs=/usr/lib/python2.6/site-packages/sqlalchemy/test/profiling.pyR –s((R>R?R ((R>R?s=/usr/lib/python2.6/site-packages/sqlalchemy/test/profiling.pyR‡s c Os‰tpJdatidjo0yddk}daWqMtj oqMXqQntdjot||||ŽSt||||ŽSdS(NthotshotiiiÿÿÿÿtcProfile(ii(tprofilerR2R3RBt ImportErrort_profile_cProfilet_profile_hotshot(RRRRRB((s=/usr/lib/python2.6/site-packages/sqlalchemy/test/profiling.pyR¢s    c s›ddk}ddk}ddk‰ddk}‡‡fd†}|iƒ|iƒ}|idtƒtƒdˆƒ|iƒ} | ||tƒdfS(Niÿÿÿÿcs ˆiˆƒS((tStats((Rtpstats(s=/usr/lib/python2.6/site-packages/sqlalchemy/test/profiling.pyR$µssresult = fn(*args, **kw)RR(RBtgcRHRtcollecttrunctxtglobalstlocals( RRRRRBRIRRtbegantended((RRHs=/usr/lib/python2.6/site-packages/sqlalchemy/test/profiling.pyRE²s0   c s¹ddk}ddk‰ddk‰ddk}‡‡fd†}|iƒˆiˆƒ}|iƒ}|iƒz|||Ž} Wd|iƒ|iƒ} |iƒX| ||| fS(NiÿÿÿÿcsˆiiˆƒS((Rtload((RAR(s=/usr/lib/python2.6/site-packages/sqlalchemy/test/profiling.pyR$Ás( RIRAt hotshot.statsRRJtProfiletstarttstoptclose( RRRRRIRRtprofRNRRO((RRAs=/usr/lib/python2.6/site-packages/sqlalchemy/test/profiling.pyRF¿s0      (sprofiledsfunction_call_countsconditional_call_count(stimescalls(t__doc__RR2tsqlalchemy.utilRtconfigt__all__tsetR!tTrueRR RCRRRRRERF(((s=/usr/lib/python2.6/site-packages/sqlalchemy/test/profiling.pyts      1A