00001 __copyright__ = """\ 00002 (c). Copyright 1990-2008, Vyper Logix Corp., All Rights Reserved. 00003 00004 Published under Creative Commons License 00005 (http://creativecommons.org/licenses/by-nc/3.0/) 00006 restricted to non-commercial educational use only., 00007 00008 See also: http://www.VyperLogix.com and http://www.pypi.info for details. 00009 00010 THE AUTHOR VYPER LOGIX CORP DISCLAIMS ALL WARRANTIES WITH REGARD TO 00011 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 00012 FITNESS, IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, 00013 INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING 00014 FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 00015 NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 00016 WITH THE USE OR PERFORMANCE OF THIS SOFTWARE ! 00017 00018 USE AT YOUR OWN RISK. 00019 """ 00020 00021 import os, sys 00022 import traceback 00023 00024 from vyperlogix import misc 00025 from vyperlogix.misc import ioTimeAnalysis 00026 00027 import types 00028 00029 def dummy(): 00030 pass 00031 00032 def init_AnalysisDataPoint(name): 00033 ioTimeAnalysis.initIOTime(name) 00034 00035 def begin_AnalysisDataPoint(name): 00036 ioTimeAnalysis.ioBeginTime(name) 00037 00038 def end_AnalysisDataPoint(name): 00039 ioTimeAnalysis.ioEndTime(name) 00040 00041 def runWithAnalysis(func=dummy,args=[],_ioElapsedTime=dummy,num_iters=None): 00042 caller = misc.callersName() 00043 ioTimeAnalysis.initIOTime('%s::%s' % (__name__,caller)) 00044 ioTimeAnalysis.ioBeginTime('%s::%s' % (__name__,caller)) 00045 val = None 00046 try: 00047 if (len(args) == 0): 00048 val = func() 00049 else: 00050 val = func(args) 00051 except: 00052 exc_info = sys.exc_info() 00053 info_string = '\n'.join(traceback.format_exception(*exc_info)) 00054 print >>sys.stderr, '(%s) Reason: %s' % (misc.funcName(),info_string) 00055 ioTimeAnalysis.ioEndTime('%s::%s' % (__name__,caller)) 00056 ioTimeAnalysis.ioTimeAnalysisReport() 00057 00058 _et = 0 00059 _key_list = [k for k in ioTimeAnalysis._ioTime.keys()] 00060 for _key in _key_list: 00061 _et += (0 if (len(_key) == 0) else ioTimeAnalysis._ioTime[_key][0]) 00062 if (_et > 0) and (num_iters is not None): 00063 _per_sec = num_iters / _et 00064 if (_per_sec > 0): 00065 _ms_per_soql = 1000 / _per_sec 00066 else: 00067 print >>sys.stderr, '(%s) 1.0 Cannot correctly report ms per iteration because there is no reported elapsed time from activities.' % (misc.funcName()) 00068 00069 return val 00070 00071 if (__name__ == '__main__'): 00072 import sys 00073 print >>sys.stdout, __copyright__ 00074 print >>sys.stderr, __copyright__ 00075 00076 00077
© Copyright 2008-2009 Vyper Logix Corp., All Right Reserved; If you reference this document or any part of this document you must use the citation verbatim (including the link) "© Copyright 2008-2009 Vyper Logix Corp., All Right Reserved."
Notice: This source code contained in this document is NOT open source and is NOT being distributed as open source.
122,241 lines of code and growing...