tests.profiling
Module Contents
Classes
Basic timer for do_time_profile. |
Functions
Run a function with a timer. |
|
Use built-in profiler to profile. |
|
The Main Event makes no sense to profiling. |
Data
This is pythonrepo testing module Template. |
API
- tests.profiling.__module__[source]
‘tests.profiling’
This is pythonrepo testing module Template.
- class tests.profiling.timewith(name='')[source][source]
Basic timer for do_time_profile.
Initialization
- property elapsed[source]
- tests.profiling.do_time_profile(func, timer_name='time_profile')[source][source]
Run a function with a timer.
Time Testing:
First some test fixtures: >>> import tests.context as context >>> from context import profiling as profiling >>>Testcase 0: test the time_profile.
>>> def doWork(): ... """Does some work.""" ... for i in range(0, 42): ... print(str("Do Task {}").format(int(i))) >>> >>> profiling.do_time_profile( ... doWork, ... timer_name=str("work time test") ... )() #doctest: -DONT_ACCEPT_BLANKLINE, +ELLIPSIS work...Start Timer... ...Do Task... work...Stop Timer... work...took ... seconds >>>
- tests.profiling.do_cprofile(func)[source][source]
Use built-in profiler to profile.
Time Testing:
First some test fixtures: >>> import tests.context as context >>> from context import profiling as profiling >>>Testcase 0: test the time_profile.
>>> def doWork(): ... """Does some work.""" ... for i in range(0, 42): ... print(str("Do Task {}").format(int(i))) >>> >>> profiling.do_cprofile( ... doWork ... )() #doctest: -DONT_ACCEPT_BLANKLINE, +ELLIPSIS Do Task 0...Do Task 10...Do Task 20...Do Task 30...Do Task 40... ...function calls in ... seconds...Ordered by: standard name... ...ncalls tottime percall cumtime percall filename:lineno(function)... ...<...>:1(doWork)...{built-in method builtins.print}... <BLANKLINE> <BLANKLINE> >>>