
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Clock Timmer is a Python library that provides a tool for logging the time and number of calls of a function in Python. It can be used as a decorator or context manager, allowing you to log the time and number of calls of a function or block of code without modifying any lines of code within the function or block.
Installation To install Clock Timmer, use the following command:
pip install python-clock-timer
To use Clock Timmer as a decorator, you can use it like this:
from clock_timer import ClockLogger
logger = ClockLogger()
@logger
def my_function():
# code of the function
After using the decorator, you can access the time and number of calls logs of the function by accessing the log attribute of the Clock Timmer object. For example, to get the number of calls and total time elapsed of the my_function, you can do the following:
print(logger.log['my_function'])
To use Clock Timmer as a context manager, you can use it like this:
from clock_timer import ClockLogger
with ClockLogger() as logger:
# code of the block
print(logger.total_elapsed)
After using the context manager, you can access the total time elapsed by accessing the elapsed attribute of the Clock Timmer object.
Here is an example of using Clock Timmer as a decorator and a context manager:
from clock_timer import ClockLogger
import time
# Using Clock Timmer as a decorator
logger = ClockLogger()
@logger
def my_function():
time.sleep(1)
my_function()
my_function()
print(logger.log['my_function'])
the output
my_function was called 1 times, total time elapsed: 1.005031s
my_function was called 2 times, total time elapsed: 2.005123s
[2, 2.0051226250000003]
import time
from clock_timer import ClockLogger
with ClockLogger() as logger:
time.sleep(1)
print(logger.total_elapsed)
The output of this example will be:
Total time elapsed: 1.003622s
1.003622042
We welcome contributions to Clock Timmer. If you have any ideas for improvements or want to report a bug, please open an issue or submit a pull request.
Clock Timmer is licensed under the MIT License. See the LICENSE file for more details.
FAQs
Awesome clock_timer created by maycuatroi
We found that python-clock-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
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.