-
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)
PyTimer(*args, **kwargs)-
args: varied (optional) -> the first arugment will be used to determine whether or not to automatically runstart()if it is present. Otherwise,start()is automatically called-
start: bool (optional) -> Automatically runstart()when creating object
-
-
kwargs: varied (optional) -> keyword arguments, five of which are checked for-
round: int (optional) -> Number of digits to round values to -
run: bool (optional) -> Do functions calls to timer object do anything, useful for disabling timer without removing code -
collect: bool (optional) -> Collect all data the is, or would be, displayed -
display: bool (optional) -> Print outputs to console -
units: str (optional) -> Units to display times in, must be in (PyTimer.seconds,PyTimer.milliseconds,PyTimer.microseconds,PyTimer.nanoseconds), if not specified, then value is converted to nearest one
-
-
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(function): 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. -
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 -> Returns list of 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 -
evaluate(block, *args, **kwargs)-> Runs blockrepstimes, then callslog()and repeatsiterationstimes.split()is called at end with message based on text of block, or name of function, ormessageif specified -
block: (str or callable) -> string block of code, or function to be timed -
args: varied -> arguments to be passed intoblockif it is a function -
kwargs: varied -> keyword arguments, three are specifically reservered for this method, the others are passed intoblockif it is a function-
reps: int (optional) -> number of reps, defaults to 10 -
iterations: int (optional) -> number of iterations, defaults to 10 -
message: str (optional) -> message to use for split, if not specified, than the message isblock.__name__ifblockis a function. Otherwise, the message isblockif it is astr
-
-
log(message="")-> Log time since start, last log, last split, or last resume, depending on which happened most recently -
message: str (optional) -> 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(**kwargs)-> allow number of reps and iterations to be set for decorator -
kwargs: varied (optional) -> keyword arguments, two of which are specified for this method-
reps: int (optional) -> number of reps for decorator, defaults to 1 -
iterations: int (optional) -> number of iterations for decorator, defaults to 10
-
-
split(message="")-> Create separate group of logs -
message: str (optional) -> 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 -
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