5.20 Scripting view

The user interface might not have all the tools that you require to extract or analyze information that is retrieved from the target device. Therefore Graphics Analyzer has a Python scripting environment that allows you to directly interface with the Graphics Analyzer trace model. You can either perform an analysis natively in Python, or output the data that you need to an external file.

The Jython interpreter

The Scripting view contains a Jython interpreter that implements the Python 2.7.0 specification. The interpreter supports the standard Python syntax and the Python standard library.

There is one interpreter per trace file. These interpreters cannot share data. Closing the Scripting view closes all interpreters. The interpreter supports loading script code in the following forms:

  • User script files that you load and run from the Scripting view.
  • Python modules that you load using the import statement in a user script. Imported user modules are found by searching based on the JYTHON_PATH environment variable, not the PYTHON_PATH environment variable.

Note:

After a script completes, all globally scoped declarations (imports, global variables, class definitions, function definitions, …) persist in the scripting environment.

For convenience, the interpreter is initialized with two extra global variables:

trace
A representation of the Graphics Analyzer internal model.
monitor
An interface to the progress bar underneath the interpreter input text area. You can use this interface to track progress in your scripts.

For more information about these objects, or any other Graphics Analyzer object, use the built-in Python help function to print API documentation. For example:

help(trace)

Graphics Analyzer also comes with some sample scripts in <install_directory>/samples/scripts/ that provide examples of different ways to perform analysis on a trace object.

The scripting console

The scripting console allows you to interact with the Jython interpreter.

You can use the Up and Down keys to move through a history of the commands you have previously executed.

Clicking Interrupt causes any running script and any created threads to stop.

Clear allows you to clear the output text area.

To reset the interpreter back to its original state, click Reset .

Loading scripts

The Scripting view contains an interactive interpreter, but for more complicated analysis it is easier to write a script in a separate Python file. The Scripting view also allows you to load Python scripts, or directories of Python scripts, from your file system. Graphics Analyzer only loads scripting files with the .py extension.

The script locations that you load are stored in your workspace and are persistent across runs of Graphics Analyzer.

To load a single script, click Add Script .

To load a directory, click Add Directory . File-system changes to this directory are reflected in Graphics Analyzer.

To remove any top-level item, click Remove . The file and directory on the file system are not affected.

Scripts are loaded and displayed in a staging area next to the interpreter. To execute a script, either double-click it or highlight it in the staging area and either right-click and select Run or press the R key.

Performance considerations

The scripting environment is powerful, but also potentially memory intensive. The following tips might help improve the performance of your scripts:

  • Holding global references to objects that you no longer need wastes memory. Delete an individual reference with the del keyword or click Reset to re-initialize the scripting environment, deleting all references.
  • Only touching the parts of the model that you are interested in keeps memory usage low.
  • Traversing the model forwards is faster than traversing backwards.
  • Printing excessively large strings to the interpreter console can slow down the Graphics Analyzer user interface. If you must write large strings, write to an external file rather than the scripting console.
Non-Confidential - RELPDF file icon PDF version101545__00_en
Copyright © 2020–2022, 2024 Arm Limited or its affiliates. All rights reserved.