Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Simple python timer to use for single lines of code, or entire functions/classes
code_timer.Timer
as a class, context manager, decorator
code_timer.timer
decoratorcode_timer.timeit
decorator to measure the time to run the same function multiple times
code_timer.Timer
As a class:
t = Timer(name="class")
t.start()
# Do something
t.stop()
As a context manager:
Useful when trying to time a recursive function
with Timer(name="context manager") as t:
# Do something
print(f"Elapsed time: {t.elapsed_time}")
As a decorator:
@Timer(name="decorator")
def stuff():
# Do something
code_timer.timer
Without braces
@timer
def your_func():
# Do something
With braces
@timer(name="my_timer")
def your_func():
# Do something
code_timer.timeit
@timeit
def your_func():
# Do something
2020-03-12 21:56:46: code_timer.INFO - Best 3 of 10000 for your_func: 0.2200 ms; 0.2220 ms; 0.2232 ms
@timeit(num_repeats=50)
def your_func():
# Do something
2020-03-12 21:56:46: code_timer.INFO - Best 3 of 50 for your_func: 0.2200 ms; 0.2220 ms; 0.2232 ms
FAQs
Custom timer for your Python coding pleasure
We found that code-timer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.