Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
util for profiling python code mainly in django projects, but can be used also on ordinary python code
django-profiler is util for profiling python code mainly in django projects
but can be used also on ordinary python code. It counts sql queries a measures
time of code execution. It logs its output via standard
python logging library and uses logger profiling
. If your profiler name
doesn't contain any empty spaces e.g. Profiler('Profiler1') django-profiler will
log all the output to the profiling.Profiler
logger.
Install via pip or copy this module into your project or into your PYTHON_PATH.
django settings.py constants
::
PROFILING_LOGGER_NAME PROFILING_SQL_QUERIES
It is possible to change default django-profiler logger name by defining PROFILING_LOGGER_NAME = 'logger_name' in your django settings.py.
To log also sql queries into profiler logger set PROFILING_SQL_QUERIES to True in your django settings.py module.
Example 1
Using context manager approach. Output will be logged to profiling logger.
::
from profiling import Profiler with Profiler('Complex Computation'): # code with some complex computations
Example 2
Using context manager approach. Output will be logged to profiling.Computation logger.
::
from profiling import Profiler with Profiler('Computation'): # code with some complex computations
Example 3
Using standard approach. Output will be logged to profiling logger.
::
from profiling import Profiler profiler = Profiler('Complex Computation') profiler.start()
profiler.stop()
Example 4
Using standard approach and starting directly in constructor. Output will be logged to profiling logger.
::
from profiling import Profiler profiler = Profiler('Complex Computation', start=True)
profiler.stop()
Example 5
Using decorator approach. Output will be logged to profiling.complex_computations logger.
::
from profiling import profile
@profile def complex_computations(): #some complex computations
Example 6
Using decorator approach. Output will be logged to profiling.ComplexClass.complex_computations logger.
::
from profiling import profile
class ComplexClass(object): @profile def complex_computations(): #some complex computations
Example 7
Using decorator approach. Output will be logged to profiling.complex_computations logger.
profile
execution stats are logged to profiling.complex_computations logger.
::
from profiling import profile
@profile(stats=True) def complex_computations(): #some complex computations
Example 8
Using decorator approach. Output will be logged to profiling.complex_computations logger.
profile
execution stats are printed to sys.stdout.
::
import sys
from profiling import profile
@profile(stats=True, stats_buffer=sys.stdout) def complex_computations(): #some complex computations
Example 9
Using decorator approach. Output will be logged to profiling.ComplexClass.complex_computations logger.
profile
stats will be logged to profiling.ComplexClass.complex_computations.
::
from profiling import profile
class ComplexClass(object) @profile(stats=True) def complex_computations(): #some complex computations
Tested on evnironment
Running tests
To run the test run command: ::
$ python test.py $ python setup.py test
| char0n (Vladimír Gorej, CodeScale s.r.o.) | email: gorej@codescale.net | web: http://www.codescale.net
FAQs
util for profiling python code mainly in django projects, but can be used also on ordinary python code
We found that django-profiler 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
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
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.