[PATCH 2/7] gitlab: add -n option to check_units

Alex Bennée posted 7 patches 4 months, 1 week ago
Maintainers: "Alex Bennée" <alex.bennee@linaro.org>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Thomas Huth <thuth@redhat.com>, Riku Voipio <riku.voipio@iki.fi>, Laurent Vivier <laurent@vivier.eu>, Alexandre Iooss <erdnaxe@crans.org>, Mahmoud Mandour <ma.mandourr@gmail.com>, Pierrick Bouvier <pierrick.bouvier@linaro.org>, Jason Wang <jasowang@redhat.com>, Richard Henderson <richard.henderson@linaro.org>
[PATCH 2/7] gitlab: add -n option to check_units
Posted by Alex Bennée 4 months, 1 week ago
Mostly a developer aid for those who want to look at the full backlog
of multiple build units.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 .gitlab-ci.d/check-units.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/.gitlab-ci.d/check-units.py b/.gitlab-ci.d/check-units.py
index cdc62ae5ee..cebef0e8be 100755
--- a/.gitlab-ci.d/check-units.py
+++ b/.gitlab-ci.d/check-units.py
@@ -30,7 +30,7 @@ def extract_build_units(cc_path):
     return build_units
 
 
-def analyse_units(build_units):
+def analyse_units(build_units, top_n):
     """
     Analyse the build units and report stats and the top 10 rebuilds
     """
@@ -44,7 +44,7 @@ def analyse_units(build_units):
                                 reverse=True)
 
     print("Most rebuilt units:")
-    for unit, count in sorted_build_units[:20]:
+    for unit, count in sorted_build_units[:top_n]:
         print(f"  {unit} built {count} times")
 
     print("Least rebuilt units:")
@@ -57,12 +57,14 @@ def analyse_units(build_units):
         description="analyse number of build units in compile_commands.json")
     parser.add_argument("cc_path", type=Path, default=None,
                         help="Path to compile_commands.json")
+    parser.add_argument("-n", type=int, default=20,
+                        help="Dump the top <n> entries")
 
     args = parser.parse_args()
 
     if path.isfile(args.cc_path) and access(args.cc_path, R_OK):
         units = extract_build_units(args.cc_path)
-        analyse_units(units)
+        analyse_units(units, args.n)
         exit(0)
     else:
         print(f"{args.cc_path} doesn't exist or isn't readable")
-- 
2.47.2


Re: [PATCH 2/7] gitlab: add -n option to check_units
Posted by Manos Pitsidianakis 4 months, 1 week ago
On Thu, Jul 10, 2025 at 1:46 PM Alex Bennée <alex.bennee@linaro.org> wrote:
>
> Mostly a developer aid for those who want to look at the full backlog
> of multiple build units.
>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  .gitlab-ci.d/check-units.py | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/.gitlab-ci.d/check-units.py b/.gitlab-ci.d/check-units.py
> index cdc62ae5ee..cebef0e8be 100755
> --- a/.gitlab-ci.d/check-units.py
> +++ b/.gitlab-ci.d/check-units.py
> @@ -30,7 +30,7 @@ def extract_build_units(cc_path):
>      return build_units
>
>
> -def analyse_units(build_units):
> +def analyse_units(build_units, top_n):
>      """
>      Analyse the build units and report stats and the top 10 rebuilds
>      """
> @@ -44,7 +44,7 @@ def analyse_units(build_units):
>                                  reverse=True)
>
>      print("Most rebuilt units:")
> -    for unit, count in sorted_build_units[:20]:
> +    for unit, count in sorted_build_units[:top_n]:
>          print(f"  {unit} built {count} times")
>
>      print("Least rebuilt units:")
> @@ -57,12 +57,14 @@ def analyse_units(build_units):
>          description="analyse number of build units in compile_commands.json")
>      parser.add_argument("cc_path", type=Path, default=None,
>                          help="Path to compile_commands.json")
> +    parser.add_argument("-n", type=int, default=20,
> +                        help="Dump the top <n> entries")
>

FYI this defaults to n=20 always, even if -n isn't given.

Either way LGTM:

Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>


>      args = parser.parse_args()
>
>      if path.isfile(args.cc_path) and access(args.cc_path, R_OK):
>          units = extract_build_units(args.cc_path)
> -        analyse_units(units)
> +        analyse_units(units, args.n)
>          exit(0)
>      else:
>          print(f"{args.cc_path} doesn't exist or isn't readable")
> --
> 2.47.2
>
>