-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added profiling decorator and makefile updates
- Loading branch information
1 parent
fa0e0db
commit 1131d29
Showing
3 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
""" | ||
Profiling function helper - used to profile function performance | ||
""" | ||
import functools | ||
import time | ||
|
||
# ******************************************************************************** # | ||
|
||
def profile_func (func) : | ||
""" | ||
Profile Logging decorator | ||
""" | ||
@functools.wraps(func) | ||
def wrapper (*args, **kwargs): | ||
start = time.time () | ||
func (*args, **kwargs) | ||
end = time.time () | ||
print (f"Elapsed time: {(end - start) *1000:.3f}ms") | ||
return wrapper | ||
|
||
# ******************************************************************************** # | ||
|
||
# usage of decorator to measure function performance | ||
# @profile_func | ||
# def add (num1: int, num2: int) : | ||
# print (f"Add {num1} and {num2}") | ||
# return num1 + num2 |