00001 __copyright__ = """\ 00002 (c). Copyright 1990-2008, Vyper Logix Corp., 00003 00004 All Rights Reserved. 00005 00006 Published under Creative Commons License 00007 (http://creativecommons.org/licenses/by-nc/3.0/) 00008 restricted to non-commercial educational use only., 00009 00010 See also: http://www.VyperLogix.com and http://www.pypi.info for details. 00011 00012 THE AUTHOR VYPER LOGIX CORP DISCLAIMS ALL WARRANTIES WITH REGARD TO 00013 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 00014 FITNESS, IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, 00015 INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING 00016 FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 00017 NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 00018 WITH THE USE OR PERFORMANCE OF THIS SOFTWARE ! 00019 00020 USE AT YOUR OWN RISK. 00021 """ 00022 00023 def timer(fn, *args, **kwargs): 00024 "Time the application of fn to args. Return (result, seconds)." 00025 import time 00026 start = time.clock() 00027 return fn(*args, **kwargs), time.clock() - start 00028 00029 ## 00030 # A wrapper which can be used to time any function 00031 def Timeit(func,number=10000,module="__main__"): 00032 00033 name = func.__name__ 00034 t = timeit.Timer("%s()"%name, "from %s import %s" % (module, name)) 00035 return "%.2f usec/pass" % (1000000*t.timeit(number=number)/number) 00036 00037 if (__name__ == '__main__'): 00038 import sys 00039 print >>sys.stdout, __copyright__ 00040 print >>sys.stderr, __copyright__ 00041 00042 #from mymodule import test 00043 00044 ## Using wrapper 00045 #print Timeit(test) 00046 ## Directly using timeit 00047 #t = timeit.Timer("test()", "from __main__ import test") 00048 #print "%.2f usec/pass" % (1000000*t.timeit(number=10000)/10000) 00049 00050
© 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...