Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build metrics report format with long placehold filenames #17679

Merged
merged 3 commits into from
Jan 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions cpp/scripts/sort_ninja_log.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#
# Copyright (c) 2021-2024, NVIDIA CORPORATION.
# Copyright (c) 2021-2025, NVIDIA CORPORATION.
#
import argparse
import os
import re
import sys
import xml.etree.ElementTree as ET
from pathlib import Path
Expand Down Expand Up @@ -144,6 +145,16 @@ def format_file_size(input_size):
return file_size_str


def replace_placeholder_patterns(input_string: str) -> str:
pattern = r'(_h_env_placehold)[_placehold]+'
return re.sub(pattern, r'\1...', input_string)


# adjust name for display
def format_file_name(name: str) -> str:
return replace_placeholder_patterns(name)


# Output chart results in HTML format
# Builds a standalone html file with no javascript or styles
def output_html(entries, sorted_list, cmp_entries, args):
Expand Down Expand Up @@ -223,7 +234,8 @@ def output_html(entries, sorted_list, cmp_entries, args):
print("<td height='20px' width='", size, "px' ", sep="", end="")
# title text is shown as hover-text by most browsers
print(color, "title='", end="")
print(name, "\n", build_time_str, "' ", sep="", end="")
display_name = format_file_name(name)
print(display_name, "\n", build_time_str, "' ", sep="", end="")
# centers the name if it fits in the box
print("align='center' nowrap>", end="")
# use a slightly smaller, fixed-width font
Expand Down Expand Up @@ -265,7 +277,8 @@ def output_html(entries, sorted_list, cmp_entries, args):
file_size_str = format_file_size(file_size)

# output entry row
print("<tr ", color, "><td>", name, "</td>", sep="", end="")
display_name = format_file_name(name)
print("<tr ", color, "><td>", display_name, "</td>", sep="", end="")
print("<td align='right'>", build_time_str, "</td>", sep="", end="")
print("<td align='right'>", file_size_str, "</td>", sep="", end="")
# output diff column
Expand Down
Loading