-
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.
- Loading branch information
xiangyang.qi
committed
Nov 9, 2022
1 parent
cc17d02
commit 0912e87
Showing
1 changed file
with
11 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import time | ||
|
||
|
||
def timer(func): | ||
def wrapper(s): | ||
start_time = time.time() | ||
str_len = func(s) | ||
end_time = time.time() | ||
print(f"func name: {func.__name__}, total cost: {round((end_time - start_time) * 1000 * 1000, 2)} ns") | ||
return str_len | ||
return wrapper |