-
Notifications
You must be signed in to change notification settings - Fork 0
API
-
seconds-> abbreviateds -
milliseconds-> abbreviatedms(10-3 s) -
microseconds-> typically abbreviation isμs, but to avoid UNICODE issues, it is abbreviatedus(10-6 s) -
nanoseconds-> abbreviatedns(10-9 s) -
rounding-> the number of digits to round displayed numbers to
-
elapsed([display=True, message=""]):None|float-> Easily check how much time has elapsed since the last call to this method. This requires that there is an initial call. The elapsed time can be displayed, optionally with a message, or the value can be returned. -
display=True:bool-> Display the resulting elapsed time, or return the value -
message="":str-> Add a message to the displayed result, will only happen ifdisplay=True -
time_it(block, *args, [reps=1, iterations=10, display=True, message=""], **kwargs):None|float-> This method is the static version oftimeand allows callable objects and strings to be timed. Ifblockiscallable, then allargsandkwargs(exceptrepsanditerations) will be passed intoblockwhen it is called. Function returns the average time of all the iterations. -
block:str|callable-> The function or string of code to be timed -
args: varied [optional] -> Any positional arguments to pass intoblockif it iscallable -
reps=1:int-> The number of repititions to do within each iteration -
iterations=10:int-> The number of iterations to time and average together -
display=True:bool-> Display the averaged time, or return the value -
message="":str-> Ifdisplay, then attach this message when displaying the time
PyTimer(start=True, [round=4, units=None, run=True, collect=False, display=True])-
start=True:bool-> Automatically runstart()when creating object, thus start recording the time here -
round=4:int-> Number of digits to round values to -
run=True:bool-> Do functions calls to timer object do anything, useful for disabling timer without removing code -
collect=False:bool-> Collect all data the is, or would be, displayed -
display=True:bool-> Whether or not to display any output -
units=None:str-> Units to display times in, must be in (PyTimer.seconds,PyTimer.milliseconds,PyTimer.microseconds,PyTimer.nanoseconds), ifNone, then all values will be automatically converted to closest unit
-
average(i):int-> Returns average of i'th split, orNoneif empty split orFalseifiis an invalid index -
i:int-> Index of split to determine average for -
averages():list-> Returns list of averages for every split, if positioniis empty, thenlist[i]isNone -
decorator(func):callable-> For use only as a decorator like@timer.decorator, this allows the function to be timed when it is called. WARNING: Do not use decorator with recursive function as this will lead to a spiral of calls within the decorator. Instead, use theevaluate()method. -
func:callable-> Function to use decorator on -
deviation(i):float-> Returns the standard deviation of splitiorNoneifiis empty split otherwiseFalseifiis an invalid index -
i:int-> Index of split to determine standard deviation for -
deviations():list-> Returnslistof standard deviations for every split, if splitiis empty thenlist[i]isNone -
display_average(i)-> Display average of splitiif valid index, if empty split or invalid index than an appropriate messages is displayed -
i:int-> index of split to display average for -
display_averages()-> Display averages for every split, if split is empty than it is skipped -
display_deviation(i)-> Display standard deviation for spliti, if empty split or invalid index than an appropriate message is displayed -
i:int-> index of split to display standard deviation for -
display_deviations()-> Display standard deviations for all splits, if split is empty than it is skipped -
display_split(i)-> Display all logged values in spliti, if split is empty or invalid index than an appropriate message is displayed -
i:int-> index of split to display logged values for -
display_splits()-> Display all logged values for all splits, if split is empty than it is skipped -
log(message="")-> Log time since start, last log, last split, or last resume, depending on which happened most recently -
message="":str-> message to attach to log -
overall_time():float-> time elapsed sincestart()orreset()in seconds. This includes time spend executing PyTimer calls. -
pause()-> pause timer -
reset()-> clear all recorded values, callstart()to update internal time values -
resume()-> start back frompause(), update internal time values -
setup_decorator([reps=1, iterations=10])-> allow number of reps and iterations to be set for decorator -
reps=1:int-> number of reps for decorator -
iterations=10:int-> number of iterations for decorator -
split(message="")-> Create separate group of logs -
message="":str-> message to be attached to split, used as name when displaying anything associated with this split -
start()-> setup internal time values, must be called manually ifstartis set toFalsewhen object was created -
time(block, *args, [reps=1, iterations=10, message=""], **kwargs)-> Runs blockrepstimes, then callslog()and repeatsiterationstimes.split()is called at end with message based on text of block, or the name of the function, ormessageif specified -
block:str|callable-> string block of code, or a function to be timed -
args: varied [optional] -> arguments to be passed intoblockif it is a function -
reps=1:int-> number of reps, defaults to 10 -
iterations=10:int-> number of iterations, defaults to 10 -
message="":str-> message to use for split, if not specified, then the message isblock.__name__ifblockis a function. Otherwise, the message isblockif it is astr -
kwargs: varied [optional]-> keyword arguments, all but the three listed above will be passed directly intoblockif it iscallable
-
times(i):list-> returns list of elapsed times for splitiorNoneif invalid index -
i:int-> index for split w/ elapsed times -
write_output(fp)-> will write all collected output to file pathfpifcollectwas set toTruewhen creating object, otherwise an appropriate message will be displayed.PermissionErrorwill be thrown if file path cannot be written to. -
fp:str-> file path to write file to