
Security News
New CVE Forecasting Tool Predicts 47,000 Disclosures in 2025
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
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
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.