All Projects → gaogaotiantian → Viztracer

gaogaotiantian / Viztracer

Licence: apache-2.0
VizTracer is a low-overhead logging/debugging/profiling tool that can trace and visualize your python code execution.

Programming Languages

python
139335 projects - #7 most used programming language
python3
1442 projects

Projects that are alternatives of or similar to Viztracer

Clockwork Chrome
Clockwork - php dev tools integrated to your browser - Chrome extension
Stars: ✭ 415 (-52.52%)
Mutual labels:  logging, debugging, profiling
Clockwork
Clockwork - php dev tools in your browser - server-side component
Stars: ✭ 4,076 (+366.36%)
Mutual labels:  logging, debugging, profiling
Stern
⎈ Multi pod and container log tailing for Kubernetes -- Friendly fork of https://github.com/wercker/stern
Stars: ✭ 268 (-69.34%)
Mutual labels:  logging, debugging
Cocoadebug
iOS Debugging Tool 🚀
Stars: ✭ 3,769 (+331.24%)
Mutual labels:  logging, debugging
Xcglogger
A debug log framework for use in Swift projects. Allows you to log details to the console (and optionally a file), just like you would have with NSLog() or print(), but with additional information, such as the date, function name, filename and line number.
Stars: ✭ 3,710 (+324.49%)
Mutual labels:  logging, debugging
kokkos-tools
Kokkos C++ Performance Portability Programming EcoSystem: Profiling and Debugging Tools
Stars: ✭ 52 (-94.05%)
Mutual labels:  debugging, profiling
thundra-agent-nodejs
Thundra Lambda Node.js Agent
Stars: ✭ 31 (-96.45%)
Mutual labels:  logging, profiling
iopipe-js
Build and run serverless apps with confidence on AWS Lambda with Tracing, Profiling, Metrics, Monitoring, and more.
Stars: ✭ 33 (-96.22%)
Mutual labels:  debugging, profiling
Snoop
A powerful set of Python debugging tools, based on PySnooper
Stars: ✭ 467 (-46.57%)
Mutual labels:  logging, debugging
Trace Nodejs
Trace is a visualised distributed tracing platform designed for microservices.
Stars: ✭ 471 (-46.11%)
Mutual labels:  debugging, profiling
Traceback with variables
Adds variables to python traceback. Simple, lightweight, controllable. Debug reasons of exceptions by logging or pretty printing colorful variable contexts for each frame in a stacktrace, showing every value. Dump locals environments after errors to console, files, and loggers. Works in Jupyter and IPython. Install with pip or conda.
Stars: ✭ 509 (-41.76%)
Mutual labels:  logging, debugging
iopipe-go
Go agent for AWS Lambda metrics, tracing, profiling & analytics
Stars: ✭ 18 (-97.94%)
Mutual labels:  debugging, profiling
clockwork-firefox
Clockwork - php dev tools integrated to your browser - Firefox add-on
Stars: ✭ 22 (-97.48%)
Mutual labels:  debugging, profiling
Home
Project Glimpse: Node Edition - Spend less time debugging and more time developing.
Stars: ✭ 260 (-70.25%)
Mutual labels:  logging, profiling
ghc-stack
Hacking GHC's Stack for Fun and Profit (featuring The Glorious Haskell Debugger v0.0.1 Pre-alpha)
Stars: ✭ 69 (-92.11%)
Mutual labels:  debugging, profiling
Rxjs Spy
A debugging library for RxJS
Stars: ✭ 576 (-34.1%)
Mutual labels:  logging, debugging
Timber Elixir
🌲 Great Elixir logging made easy
Stars: ✭ 226 (-74.14%)
Mutual labels:  logging, debugging
Utern
Multi group and stream log tailing for AWS CloudWatch Logs.
Stars: ✭ 241 (-72.43%)
Mutual labels:  logging, debugging
Log Process Errors
Show some ❤️ to Node.js process errors
Stars: ✭ 424 (-51.49%)
Mutual labels:  logging, debugging
Stern
⎈ Multi pod and container log tailing for Kubernetes
Stars: ✭ 5,614 (+542.33%)
Mutual labels:  logging, debugging

VizTracer

build flake8 readthedocs coverage pypi support-version license commit twitter

VizTracer is a low-overhead logging/debugging/profiling tool that can trace and visualize your python code execution.

You can take a look at the demo result of multiple example programs. The UI is powered by Chrome Trace Viewer. Use "AWSD" to zoom/navigate. More help can be found by clicking "?" on the top right corner.

example_img

Highlights

  • Detailed function entry/exit information on timeline with source code
  • Super easy to use, no source code change for most features, no package dependency
  • Optional function filter to ignore functions you are not interested
  • Custom events to log and track arbitrary data through time
  • Log arbitrary function/variable using RegEx without code change
  • Stand alone HTML report with powerful front-end, or chrome-compatible json
  • Works on Linux/MacOS/Windows

Install

The prefered way to install VizTracer is via pip

pip install viztracer

Basic Usage

Command Line

Assume you have a python script to run:

python3 my_script.py arg1 arg2

You can simply use VizTracer by

viztracer my_script.py arg1 arg2

which will generate a result.html file in the directory you run this command, which you can open with Chrome.

You can also generate json file or gz file and load it with perfetto or chrome://tracing/.

viztracer -o result.json my_script.py arg1 arg2
viztracer -o result.json.gz my_script.py arg1 arg2

Use vizviewer to open the reports to save trouble

# Open with chrome trace viewer that shows source code
vizviewer result.html
# Open with perfetto
vizviewer result.json
vizviewer result.json.gz

Or add --open to open the reports right after tracing

# Open with chrome trace viewer that shows source code
viztracer --open my_scripy.py arg1 arg2
# Open with perfetto
viztracer -o result.json --open my_script.py arg1 arg2
viztracer -o result.json.gz --open my_script.py arg1 arg2

As Chrome Trace Viewer is already deprecated, we will gradually lean towards perfetto which is much faster when loading large trace files.

Inline

You can also manually start/stop VizTracer in your script as well.

from viztracer import VizTracer

tracer = VizTracer()
tracer.start()
# Something happens here
tracer.stop()
tracer.save() # also takes output_file as an optional argument

Or, you can do it with with statement

with VizTracer(output_file="optional.html") as tracer:
    # Something happens here

Advanced Usage

Trace Filter

VizTracer can filter out the data you don't want to reduce overhead and keep info of a longer time period before you dump the log.

Extra Logs without Code Change

VizTracer can log extra information without changing your source code

Add Custom Event

VizTracer supports inserting custom events while the program is running. This works like a print debug, but you can know when this print happens while looking at trace data.

Misc

Multi Thread Support

VizTracer supports python native threading module without the need to do any modification to your code. Just start VizTracer before you create threads and it will just work.

example_img

Multi Process Support

VizTracer supports subprocess with --log_subprocess and multiprocessing or os.fork() with --log_multiprocess. For more general multi-process cases, VizTracer can support with some extra steps.

Refer to multi process docs for details

Async Support

VizTracer supports asyncio natively, but could enhance the report by using --log_async.

Refer to async docs for details

Remote attach

VizTracer supports remote attach to a process as long as you installed VizTracer on that process.

Refer to remote attach docs

JSON alternative

VizTracer needs to dump the internal data to json format. It is recommended for the users to install orjson, which is much faster than the builtin json library. VizTracer will try to import orjson and fall back to the builtin json library if orjson does not exist.

Virtual Debug

You can virtually debug your program with you saved json report. The interface is very similar to pdb. Even better, you can go back in time because VizTracer has all the info recorded for you.

vdb <your_json_report>

Refer to the docs for detailed commands

Performance

VizTracer will introduce 2x to 3x overhead in the worst case. The overhead is much better if there are less function calls or if filters are applied correctly.

An example run for test_performance with Python 3.8 / Ubuntu 18.04.4 on Github VM

fib:
0.000678067(1.00)[origin]
0.019880272(29.32)[py] 0.011103901(16.38)[parse] 0.021165599(31.21)[json]
0.001344933(1.98)[c] 0.008181911(12.07)[parse] 0.015789866(23.29)[json]
0.001472846(2.17)[cProfile]

hanoi     (6148, 4100):
0.000550255(1.00)[origin]
0.016343521(29.70)[py] 0.007299123(13.26)[parse] 0.016779364(30.49)[json]
0.001062505(1.93)[c] 0.006416136(11.66)[parse] 0.011463236(20.83)[json]
0.001144914(2.08)[cProfile]

qsort     (8289, 5377):
0.002817679(1.00)[origin]
0.052747431(18.72)[py] 0.011339725(4.02)[parse] 0.023644345(8.39)[json]
0.004767673(1.69)[c] 0.008735166(3.10)[parse] 0.017173703(6.09)[json]
0.007248019(2.57)[cProfile]

slow_fib  (1135, 758):
0.028759652(1.00)[origin]
0.033994071(1.18)[py] 0.001630461(0.06)[parse] 0.003386635(0.12)[json]
0.029481623(1.03)[c] 0.001152415(0.04)[parse] 0.002191417(0.08)[json]
0.028289305(0.98)[cProfile]

Documentation

For full documentation, please see https://viztracer.readthedocs.io/en/stable

Bugs/Requests

Please send bug reports and feature requests through github issue tracker. VizTracer is currently under development now and it's open to any constructive suggestions.

License

Copyright Tian Gao, 2020.

Distributed under the terms of the Apache 2.0 license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].