Skip to content

Commit

Permalink
Add Python timeline viewer (#39)
Browse files Browse the repository at this point in the history
This PR is the first commit of the Timeline Viewer, which is functional 
but still needs further refactoring and documentation needs adding.
  • Loading branch information
solidpixel authored Jan 7, 2025
1 parent 9434893 commit db22db2
Show file tree
Hide file tree
Showing 456 changed files with 27,382 additions and 17 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ jobs:
- name: Check code style
run: |
python3 -m pycodestyle ./*.py
python3 -m pycodestyle ./lglpy
python3 -m pycodestyle ./generator
python3 -m pycodestyle --config .pycodestyle.ini ./*.py
python3 -m pycodestyle --config .pycodestyle.ini ./lglpy
python3 -m pycodestyle --config .pycodestyle.ini ./generator
- name: Check typing
run: |
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ build*
# Data files and build outputs
*.gputl
*.log
*.perfetto
*.so

# Build and debug output files
/.cache
/.mypy_cache
/bin*
/log*
/x_*
10 changes: 10 additions & 0 deletions .mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[mypy]
exclude = lglpy/timeline/protos/.*\.py
ignore_missing_imports = True
disable_error_code = annotation-unchecked

[mypy-lglpy.timeline.data.raw_trace]
disable_error_code = attr-defined

[mypy-google.*]
ignore_missing_imports = True
4 changes: 4 additions & 0 deletions .pycodestyle.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[pycodestyle]
exclude = lglpy/timeline/protos
ignore = E402,E126,E127
max-line-length = 80
18 changes: 9 additions & 9 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fail-under=10
#from-stdin=

# Files or directories to be skipped. They should be base names, not paths.
ignore=CVS
ignore=CVS,protos

# Add files or directories matching the regular expressions patterns to the
# ignore-list. The regex matches against paths and can be in Posix or Windows
Expand All @@ -64,7 +64,7 @@ ignore-patterns=^\.#
# manipulated during runtime and thus existing member attributes cannot be
# deduced by static analysis). It supports qualified module names, as well as
# Unix pattern matching.
ignored-modules=
ignored-modules=cairo,protos

# Python code to execute, usually for sys.path manipulation such as
# pygtk.require().
Expand All @@ -73,7 +73,7 @@ ignored-modules=
# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the
# number of processors available to use, and will cap the count on Windows to
# avoid hangs.
jobs=1
jobs=0

# Control the amount of potential inferred values when inferring a single
# object. This can help the performance when dealing with large functions or
Expand Down Expand Up @@ -293,7 +293,7 @@ ignored-parents=
max-args=5

# Maximum number of attributes for a class (see R0902).
max-attributes=7
max-attributes=12

# Maximum number of boolean expressions in an if statement (see R0916).
max-bool-expr=5
Expand Down Expand Up @@ -342,7 +342,7 @@ indent-after-paren=4
indent-string=' '

# Maximum number of characters on a single line.
max-line-length=100
max-line-length=80

# Maximum number of lines in a module.
max-module-lines=1000
Expand Down Expand Up @@ -436,7 +436,8 @@ disable=raw-checker-failed,
use-implicit-booleaness-not-comparison-to-string,
use-implicit-booleaness-not-comparison-to-zero,
use-symbolic-message-instead,
duplicate-code
duplicate-code,
arguments-differ

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand All @@ -456,8 +457,7 @@ timeout-methods=requests.api.delete,requests.api.get,requests.api.head,requests.

# List of note tags to take in consideration, separated by a comma.
notes=FIXME,
XXX,
TODO
XXX

# Regular expression of note tags to take in consideration.
notes-rgx=
Expand Down Expand Up @@ -521,7 +521,7 @@ ignore-imports=yes
ignore-signatures=yes

# Minimum lines number of a similarity.
min-similarity-lines=4
min-similarity-lines=10


[SPELLING]
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 Arm Limited
Copyright (c) 2024-2025 Arm Limited

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
79 changes: 79 additions & 0 deletions lgl_mali_trace_viewer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# SPDX-License-Identifier: MIT
# -----------------------------------------------------------------------------
# Copyright (c) 2024-2025 Arm Limited
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the 'Software'), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# -----------------------------------------------------------------------------
'''
TODO
'''

import argparse
import sys

from lglpy.timeline.gui.window import Window


def parse_cli():
'''
Parse the command line.
Returns:
Return an argparse results object.
'''
parser = argparse.ArgumentParser()

parser.add_argument('-s', '--style', dest='style',
choices=('light', 'dark'), default='dark',
help='GUI skin to use')

parser.add_argument('input', nargs='?', metavar='PERFETTO_IN',
type=argparse.FileType('rb'), default=None,
help='input Perfetto file to load')

parser.add_argument('input2', nargs='?', metavar='GPUTL_IN',
type=argparse.FileType('rb'), default=None,
help='input GPU timeline file to load')

args = parser.parse_args()
return args


def main():
'''
Generate a coverage report on stdout.
'''
args = parse_cli()

# Start the GUI - this enters the GTK message loop
trace_file_name = None
if args.input:
trace_file_name = args.input.name
args.input.close()

metadata_file_name = None
if args.input2:
metadata_file_name = args.input2.name
args.input2.close()

Window(args.style, trace_file_name, metadata_file_name)


if __name__ == '__main__':
sys.exit(main())
2 changes: 1 addition & 1 deletion lglpy/comms/service_gpu_timeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def handle_render_pass(self, msg: Any) -> None:

# If this is a continuation then merge records
if last_render_pass and (last_render_pass['tid'] == msg['tid']):
# Don't accumulate if tagID is flagged as ambiguous
# Don't accumulate if tag_id is flagged as ambiguous
if last_render_pass['drawCallCount'] != -1:
last_render_pass['drawCallCount'] += msg['drawCallCount']

Expand Down
30 changes: 30 additions & 0 deletions lglpy/timeline/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# SPDX-License-Identifier: MIT
# -----------------------------------------------------------------------------
# Copyright (c) 2024-2025 Arm Limited
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the 'Software'), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# -----------------------------------------------------------------------------
'''
TODO
'''

import sys
import os

sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))
Empty file added lglpy/timeline/data/__init__.py
Empty file.
Loading

0 comments on commit db22db2

Please sign in to comment.