Add decorator for timing
This commit is contained in:
parent
b7be53d5c5
commit
5ecda2c66c
@ -10,7 +10,7 @@ import inspect
|
|||||||
|
|
||||||
def create_problem():
|
def create_problem():
|
||||||
with open(Problem, "w+") as f:
|
with open(Problem, "w+") as f:
|
||||||
template = inspect.cleandoc(f'''#!/usr/bin/python3
|
template = inspect.cleandoc(f'''#!/usr/bin/env python3
|
||||||
"""
|
"""
|
||||||
Created on {today}
|
Created on {today}
|
||||||
|
|
||||||
@ -21,7 +21,10 @@ def create_problem():
|
|||||||
https://projecteuler.net/problem={args['problem']}
|
https://projecteuler.net/problem={args['problem']}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from utils import timeit
|
||||||
|
|
||||||
|
|
||||||
|
@timeit("Problem {args['problem']}")
|
||||||
def compute():
|
def compute():
|
||||||
"""
|
"""
|
||||||
# Statement
|
# Statement
|
||||||
@ -32,7 +35,7 @@ def create_problem():
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
print("Result for problem {args['problem']}: ", compute())
|
print(f"Result for problem {args['problem']}: {{compute()}}")
|
||||||
''')
|
''')
|
||||||
|
|
||||||
f.write(template)
|
f.write(template)
|
||||||
@ -40,7 +43,7 @@ def create_problem():
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
today = datetime.datetime.now().strftime("%a %b %d %H:%M:%S %Y")
|
today = datetime.datetime.now().strftime("%d %b %Y")
|
||||||
parser = ArgumentParser(description=__doc__)
|
parser = ArgumentParser(description=__doc__)
|
||||||
# Add your arguments here
|
# Add your arguments here
|
||||||
parser.add_argument("-p", "--problem",
|
parser.add_argument("-p", "--problem",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user