Package: palanteer
Look into Palanteer and get an omniscient view of your programPalanteer is a set of lean and efficient tools to improve the quality of software for Python programs (and C++).Simple code instrumentation, mostly automatic in Python, delivers powerful features:Collection of meaningful atomic eventson timings, memory, locks wait and usage, context switches, data values..Visual and interactive observationof records: hierarchical logs, timeline, plot, histogram, flame graph...Remote command call and events observation can be scripted in Python: deep testing has never been simplerExecution of unmodified Python programs can be analyzed directly with a syntax similar to the one ofcProfile:Functions enter/leaveInterpreter memory allocationsAll raised exceptionsGarbage collection runsSupport of multithread, coroutines, asyncio/geventThe collected events can either beprocessed automatically by an online script, or analyzed with theseparate viewer(see last section):Palanteer is an efficient, lean and comprehensive solution for better and enjoyable software development!UsageProfiling and monitoring can be done:With unmodified code:python -m palanteer [options] <your script>This syntax is similar to thecProfileusage and no script modification is required.By default, it tries to connect to a Palanteer server. With options, offline profiling can be selected.Launchpython -m palanteerfor help or refer to thedocumentation.With code instrumentation:Please refer to thedocumentationfor details.Manual instrumentation can provide additional valuable information compared to just the automatic function profiling, like data, locks, ...The manual instrumentation may also include remotely callable commands (Command Line Interface, aka CLI), useful for configuration and testing.Here is a working example:#! /usr/bin/env python3importsysimportrandomfrompalanteerimport*globalMinValue,globalMaxValue=0,10# Handler (=implementation) of the example CLI, which sets the rangedefsetBoundsCliHandler(minValue,maxValue):# 2 parameters (both integer) as declaredglobalglobalMinValue,globalMaxValueifminValue>maxValue:# Case where the CLI execution fails (non null status). The text answer contains some information about itreturn1,"Minimum value (%d) shall be lower than the maximum value (%d)"%(minValue,maxValue)# Modify the state of the programglobalMinValue,globalMaxValue=minValue,maxValue# CLI execution was successful (null status)return0,""defmain(argv):globalglobalMinValue,globalMaxValueplInitAndStart("example")# Start the instrumentationplDeclareThread("Main")# Declare the current thread as "Main", so that it can be identified more easily in the scriptplRegisterCli(setBoundsCliHandler,"config:setRange","min=int max=int","Sets the value bounds of the random generator")# Declare the CLIplFreezePoint()# Add a freeze point here to be able to configure the program at a controlled momentplBegin("Generate some random values")foriinrange(100000):value=int(globalMinValue+random.random()*(globalMaxValue+1-globalMinValue))plData("random data",value)# Here are the "useful" valuesplEnd("")# Shortcut for plEnd("Generate some random values")plStopAndUninit()# Stop and uninitialize the instrumentation# Bootstrapif__name__=="__main__":main(sys.argv)Installation of the instrumentation moduleLatest official release directly from the PyPI storage (from sources on Linux, binary on Windows)pipinstallpalanteerDirectly from GitHub sources (top of tree, may be unstable)pipinstall"git+https://github.com/dfeneyrou/palanteer#egg=palanteer&subdirectory=python"From locally retrieved sourcesThis method ensures that the viewer and scripting module are consistent with the intrumentation libraries.Get the sources:gitclonehttps://github.com/dfeneyrou/palanteercdpalanteer
mkdirbuildcdbuildBuild on Linux:cmake..-DCMAKE_BUILD_TYPE=Release
make-j$(nproc)installBuild on Windows:(vcvarsall.bator equivalent shall be called beforehand, so that the MSVC compiler is accessible)cmake..-DCMAKE_BUILD_TYPE=Release-G"NMake Makefiles"nmakeinstallImportant!To be useful, this module requires at least a "server side":thegraphical viewerfor visual analysis (online or offline) of the collected eventsthe Pythonscripting modulepalanteer_scriptingfor automated remote usage of the collected events: KPI extraction, tests, monitoring...NOTE 1: Installing from local sources provide all components: instrumentation module, scripting module, graphical viewer, test examples and documentation.NOTE 2: It isstronglyrecommended to have matching versions between the server and the instrumentation sides