Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
timer
is a library to time your Python code.
pip install timer4 # not timer
timer
uses with
statement to watch how long your code running:import time
from timer import Timer
with Timer().watch_and_report(msg='test'):
# running code that do lots of computation
time.sleep(1.0)
# when the code reach this part, it will output the message and the time it tooks.
# for example:
# test: 10.291 seconds
watch
method instead. Whenever you've done, call report
.import time
from timer import Timer
# you can either create a timer variable first, or use Timer.get_instance()
# that will return a singleton variable.
total = 0
for item in range(7):
# only measure the part that we want
with Timer.get_instance().watch("sum of square"):
total += item ** 2
time.sleep(0.2)
# doing other things that we don't want to measure
time.sleep(0.8)
Timer.get_instance().report()
You can also use different way to print the message, such as using logging by passing a printing function to the report method: report(print_fn=logger.info)
You can also choose to append the result to a file report(append_to_file='/tmp/runtime.csv')
. This is useful if you want to measure runtime of your method and put it to a file to plot it later.
FAQs
Timing Python code made easy
We found that timer4 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.