2023-07-10 23:22:38

by Anup Sharma

[permalink] [raw]
Subject: [PATCH v3 1/6] scripts: python: Add initial script file with imports

Added the necessary modules, including the Perf-Trace-Util
library, and defines the required functions and variables.
It leverages the perf_trace_context and Core modules for
tracing and processing events. Also added usage information.

Signed-off-by: Anup Sharma <[email protected]>
---
.../scripts/python/firefox-gecko-converter.py | 28 +++++++++++++++++++
1 file changed, 28 insertions(+)
create mode 100644 tools/perf/scripts/python/firefox-gecko-converter.py

diff --git a/tools/perf/scripts/python/firefox-gecko-converter.py b/tools/perf/scripts/python/firefox-gecko-converter.py
new file mode 100644
index 000000000000..5b342641925c
--- /dev/null
+++ b/tools/perf/scripts/python/firefox-gecko-converter.py
@@ -0,0 +1,28 @@
+# firefox-gecko-converter.py - Convert perf record output to Firefox's gecko profile format
+# SPDX-License-Identifier: GPL-2.0
+#
+# The script converts perf.data to Gecko Profile Format,
+# which can be read by https://profiler.firefox.com/.
+#
+# Usage:
+#
+# perf record -a -g -F 99 sleep 60
+# perf script firefox-gecko-converter.py > output.json
+
+import os
+import sys
+import json
+from functools import reduce
+
+# Add the Perf-Trace-Util library to the Python path
+sys.path.append(os.environ['PERF_EXEC_PATH'] + \
+ '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
+
+from perf_trace_context import *
+from Core import *
+
+def trace_end():
+ pass
+
+def process_event(param_dict):
+ pass
--
2.34.1



2023-07-12 17:44:09

by Ian Rogers

[permalink] [raw]
Subject: Re: [PATCH v3 1/6] scripts: python: Add initial script file with imports

On Mon, Jul 10, 2023 at 4:09 PM Anup Sharma <[email protected]> wrote:
>
> Added the necessary modules, including the Perf-Trace-Util
> library, and defines the required functions and variables.
> It leverages the perf_trace_context and Core modules for
> tracing and processing events. Also added usage information.
>
> Signed-off-by: Anup Sharma <[email protected]>

Acked-by: Ian Rogers <[email protected]>

> ---
> .../scripts/python/firefox-gecko-converter.py | 28 +++++++++++++++++++
> 1 file changed, 28 insertions(+)
> create mode 100644 tools/perf/scripts/python/firefox-gecko-converter.py
>
> diff --git a/tools/perf/scripts/python/firefox-gecko-converter.py b/tools/perf/scripts/python/firefox-gecko-converter.py
> new file mode 100644
> index 000000000000..5b342641925c
> --- /dev/null
> +++ b/tools/perf/scripts/python/firefox-gecko-converter.py
> @@ -0,0 +1,28 @@
> +# firefox-gecko-converter.py - Convert perf record output to Firefox's gecko profile format
> +# SPDX-License-Identifier: GPL-2.0
> +#
> +# The script converts perf.data to Gecko Profile Format,
> +# which can be read by https://profiler.firefox.com/.
> +#
> +# Usage:
> +#
> +# perf record -a -g -F 99 sleep 60
> +# perf script firefox-gecko-converter.py > output.json
> +
> +import os
> +import sys
> +import json
> +from functools import reduce
> +

nit: technically some of these imports should be added when necessary
in the code.

> +# Add the Perf-Trace-Util library to the Python path
> +sys.path.append(os.environ['PERF_EXEC_PATH'] + \
> + '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
> +
> +from perf_trace_context import *
> +from Core import *
> +
> +def trace_end():
> + pass
> +
> +def process_event(param_dict):

nit: (this is likely addressed in later patches) you can add return
and parameter types here to aid understanding of the code. Function
comments are also useful.

> + pass
> --
> 2.34.1
>

2023-07-17 16:30:32

by Anup Sharma

[permalink] [raw]
Subject: Re: [PATCH v3 1/6] scripts: python: Add initial script file with imports

On Wed, Jul 12, 2023 at 09:50:40AM -0700, Ian Rogers wrote:
> On Mon, Jul 10, 2023 at 4:09 PM Anup Sharma <[email protected]> wrote:
> >
> > Added the necessary modules, including the Perf-Trace-Util
> > library, and defines the required functions and variables.
> > It leverages the perf_trace_context and Core modules for
> > tracing and processing events. Also added usage information.
> >
> > Signed-off-by: Anup Sharma <[email protected]>
>
> Acked-by: Ian Rogers <[email protected]>
>
> > ---
> > .../scripts/python/firefox-gecko-converter.py | 28 +++++++++++++++++++
> > 1 file changed, 28 insertions(+)
> > create mode 100644 tools/perf/scripts/python/firefox-gecko-converter.py
> >
> > diff --git a/tools/perf/scripts/python/firefox-gecko-converter.py b/tools/perf/scripts/python/firefox-gecko-converter.py
> > new file mode 100644
> > index 000000000000..5b342641925c
> > --- /dev/null
> > +++ b/tools/perf/scripts/python/firefox-gecko-converter.py
> > @@ -0,0 +1,28 @@
> > +# firefox-gecko-converter.py - Convert perf record output to Firefox's gecko profile format
> > +# SPDX-License-Identifier: GPL-2.0
> > +#
> > +# The script converts perf.data to Gecko Profile Format,
> > +# which can be read by https://profiler.firefox.com/.
> > +#
> > +# Usage:
> > +#
> > +# perf record -a -g -F 99 sleep 60
> > +# perf script firefox-gecko-converter.py > output.json
> > +
> > +import os
> > +import sys
> > +import json
> > +from functools import reduce
> > +
>
> nit: technically some of these imports should be added when necessary
> in the code.

Noted.

> > +# Add the Perf-Trace-Util library to the Python path
> > +sys.path.append(os.environ['PERF_EXEC_PATH'] + \
> > + '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
> > +
> > +from perf_trace_context import *
> > +from Core import *
> > +
> > +def trace_end():
> > + pass
> > +
> > +def process_event(param_dict):
>
> nit: (this is likely addressed in later patches) you can add return
> and parameter types here to aid understanding of the code. Function
> comments are also useful.

Noted.

> > + pass
> > --
> > 2.34.1
> >