freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Git][freetype/freetype][GSoC-2023-Ahmet] html dirs


From: @goksu
Subject: [Git][freetype/freetype][GSoC-2023-Ahmet] html dirs
Date: Tue, 11 Jul 2023 21:53:11 +0000

Ahmet Göksu pushed to branch GSoC-2023-Ahmet at FreeType / FreeType

Commits:

  • ceb8fab9
    by goksu at 2023-07-12T00:52:31+03:00
    html dirs
    

2 changed files:

Changes:

  • builds/testing.mk
    ... ... @@ -5,14 +5,14 @@ FTBENCH_BIN = $(OBJ_DIR)/bench.o
    5 5
     FTBENCH_FLAG ?= -c 200
    
    6 6
     INCLUDES = -I$(TOP_DIR)/include
    
    7 7
     FONTS = $(wildcard $(FTBENCH_DIR)/fonts/*.ttf)
    
    8
    -BASELINE = $(addprefix $(FTBENCH_DIR)/baseline/, $(notdir $(FONTS:.ttf=.txt)))
    
    9
    -BENCHMARK = $(addprefix $(FTBENCH_DIR)/benchmark/, $(notdir $(FONTS:.ttf=.txt)))
    
    10
    -BASELINE_DIR = $(FTBENCH_DIR)/baseline/
    
    11
    -BENCHMARK_DIR = $(FTBENCH_DIR)/benchmark/
    
    8
    +BASELINE_DIR = $(OBJ_DIR)/baseline/
    
    9
    +BENCHMARK_DIR = $(OBJ_DIR)/benchmark/
    
    10
    +BASELINE = $(addprefix $(BASELINE_DIR), $(notdir $(FONTS:.ttf=.txt)))
    
    11
    +BENCHMARK = $(addprefix $(BENCHMARK_DIR), $(notdir $(FONTS:.ttf=.txt)))
    
    12 12
     BASELINE_INFO = $(BASELINE_DIR)info.txt
    
    13 13
     BENCHMARK_INFO = $(BENCHMARK_DIR)info.txt
    
    14 14
     HTMLCREATOR = $(FTBENCH_DIR)/src/tohtml.py
    
    15
    -HTMLFILE = $(TOP_DIR)/benchmark.html
    
    15
    +HTMLFILE = $(OBJ_DIR)/benchmark.html
    
    16 16
     
    
    17 17
     # Create directories for baseline and benchmark
    
    18 18
     $(OBJ_DIR) $(BASELINE_DIR) $(BENCHMARK_DIR):
    
    ... ... @@ -21,7 +21,7 @@ $(OBJ_DIR) $(BASELINE_DIR) $(BENCHMARK_DIR):
    21 21
     # Build ftbench
    
    22 22
     $(FTBENCH_BIN): $(FTBENCH_SRC) | $(OBJ_DIR)
    
    23 23
     	@echo "Building ftbench..."
    
    24
    -	$(CC) $(INCLUDES) $< -lfreetype -o $@
    
    24
    +	@$(CC) $(INCLUDES) $< -lfreetype -o $@
    
    25 25
     
    
    26 26
     # Create a baseline
    
    27 27
     .PHONY: baseline
    
    ... ... @@ -49,7 +49,7 @@ benchmark: $(FTBENCH_BIN) $(BENCHMARK_DIR)
    49 49
     	@$(foreach font, $(FONTS), \
    
    50 50
     		$(FTBENCH_BIN) $(FTBENCH_FLAG) $(font) >> $(BENCHMARK_DIR)$(notdir $(font:.ttf=.txt)); \
    
    51 51
     	)
    
    52
    -	@$(PYTHON) $(HTMLCREATOR)
    
    52
    +	@$(PYTHON) $(HTMLCREATOR) $(OBJ_DIR)
    
    53 53
     	@echo "Benchmark created."
    
    54 54
     
    
    55 55
     .PHONY: clean-benchmark
    

  • src/tools/ftbench/src/tohtml.py
    1 1
     import os
    
    2 2
     import re
    
    3
    +import sys
    
    3 4
     
    
    4 5
     # Create the HTML file
    
    5
    -current_dir = os.path.dirname(os.path.abspath(__file__))
    
    6
    -project_root = os.path.abspath(os.path.join(current_dir, '../../../../'))
    
    6
    +project_root = sys.argv[1]
    
    7 7
     benchmark_html = os.path.join(project_root, 'benchmark.html')
    
    8 8
     
    
    9 9
     # GitLab URL
    
    10 10
     gitlab_url = 'https://gitlab.freedesktop.org/freetype/freetype/-/commit/'
    
    11 11
     
    
    12
    +# CSS style
    
    13
    +CSS_STYLE = """
    
    14
    +  <style>
    
    15
    +    table {
    
    16
    +        
    
    17
    +        }
    
    18
    +    th, td {
    
    19
    +        padding: 3px;
    
    20
    +      text-align: center;
    
    21
    +    }
    
    22
    +    th {
    
    23
    +      background-color: #ccc;
    
    24
    +      color: black;
    
    25
    +    }
    
    26
    +    .warning{
    
    27
    +        color: red;
    
    28
    +    }
    
    29
    +    .col1 {
    
    30
    +        background-color: #eee;
    
    31
    +        }   
    
    32
    +    
    
    33
    +    .highlight {
    
    34
    +      background-color: #0a0;
    
    35
    +    }
    
    36
    +  </style>
    
    37
    +"""
    
    38
    +
    
    12 39
     # Directories
    
    13
    -baseline_dir = os.path.join(project_root, 'src/tools/ftbench/baseline')
    
    14
    -benchmark_dir = os.path.join(project_root, 'src/tools/ftbench/benchmark')
    
    40
    +baseline_dir = os.path.join(project_root, 'baseline')
    
    41
    +benchmark_dir = os.path.join(project_root, 'benchmark')
    
    15 42
     
    
    16 43
     # Open HTML file for writing
    
    17 44
     with open(benchmark_html, 'w') as html_file:
    
    18
    -    html_file.write('<html>\n<head>\n<title>Benchmark Results</title>\n</head>\n<body>\n<h1>Benchmark Results</h1>\n')
    
    45
    +    html_file.write(f'<html>\n<head>\n<title>Benchmark Results</title>\n{CSS_STYLE}</head>\n<body>\n<h1>Benchmark Results</h1>\n')
    
    19 46
     
    
    20 47
         # If it's the info file, we want to handle it differently
    
    21 48
         with open(os.path.join(baseline_dir, "info.txt"), 'r') as f:
    
    ... ... @@ -25,7 +52,7 @@ with open(benchmark_html, 'w') as html_file:
    25 52
     
    
    26 53
         # Check if commit ids are the same
    
    27 54
         if baseline_info[1].strip() == benchmark_info[1].strip():
    
    28
    -        html_file.write('<h2 style="color:red;">Warning: Baseline and Benchmark have the same commit ID</h2>\n')
    
    55
    +        html_file.write('<h2 class="warning">Warning: Baseline and Benchmark have the same commit ID</h2>\n')
    
    29 56
             
    
    30 57
         baseline_info[1] = '<a href="">{}</a>\n'.format(gitlab_url, baseline_info[1].strip(), baseline_info[1][:8])
    
    31 58
         
    
    ... ... @@ -37,10 +64,11 @@ with open(benchmark_html, 'w') as html_file:
    37 64
         html_file.write('<tr><th>Info</th><th>Baseline</th><th>Benchmark</th></tr>\n')
    
    38 65
         info_list = ['Parameters', 'Commit ID', 'Commit Date', 'Branch']
    
    39 66
         for info, baseline_line, benchmark_line in zip(info_list, baseline_info, benchmark_info):
    
    40
    -        html_file.write('<tr><td>{}</td><td>{}</td><td>{}</td></tr>\n'.format(info, baseline_line.strip(), benchmark_line.strip()))
    
    41
    -    html_file.write('</table><br/>\n')
    
    42
    -
    
    67
    +        html_file.write('<tr><td class="col1">{}</td><td>{}</td><td>{}</td></tr>\n'.format(info, baseline_line.strip(), benchmark_line.strip()))
    
    68
    +    html_file.write('</table><br/>')
    
    69
    +    html_file.write('*Smaller values mean faster operation<br/>\n')
    
    43 70
         # Traverse through the 'baseline' directory
    
    71
    +    
    
    44 72
         for filename in os.listdir(baseline_dir):
    
    45 73
             if filename != 'info.txt':
    
    46 74
                 
    
    ... ... @@ -54,28 +82,29 @@ with open(benchmark_html, 'w') as html_file:
    54 82
                     if line.startswith("ftbench results for font"):
    
    55 83
                         fontname = line.split('/')[-1].strip("'")[:-2]
    
    56 84
     
    
    57
    -
    
    85
    +            
    
    58 86
                 # Write results to HTML
    
    59 87
                 html_file.write('<h2>Results for {}</h2>\n'.format(fontname))
    
    60 88
                 html_file.write('<table border="1">\n')
    
    61
    -            html_file.write('<tr><th> Test </th><th> Baseline </th><th> Benchmark </th><th> Difference </th></tr>\n')
    
    62
    -
    
    89
    +            html_file.write('<tr><th> Test </th><th><a href="">Baseline</a> (&#181;s/op)</th><th> <a href="">Benchmark</a> (&#181;s/op)</th><th> Difference (%)</th></tr>\n'.format(os.path.join(baseline_dir,fontname[:-4]),os.path.join(benchmark_dir,fontname[:-4])))
    
    90
    +            
    
    63 91
                 for baseline_line, benchmark_line in zip(baseline_results, benchmark_results):
    
    64 92
                     if baseline_line.startswith('  '):
    
    65
    -                    baseline_match = re.match(r'  (\w+(\s\(\w+\))?)\s+(\d+\.\d+)\s', baseline_line)
    
    66
    -                    benchmark_match = re.match(r'  (\w+(\s\(\w+\))?)\s+(\d+\.\d+)\s', benchmark_line)
    
    93
    +                    baseline_match = re.match(r'  (.*\S)\s+(\d+\.\d+)\s', baseline_line)
    
    94
    +
    
    95
    +                    benchmark_match = re.match(r'  (.*\S)\s+(\d+\.\d+)\s', benchmark_line)
    
    67 96
     
    
    68 97
                         if baseline_match and benchmark_match:
    
    69
    -                        baseline_value = float(baseline_match.group(3))
    
    70
    -                        benchmark_value = float(benchmark_match.group(3))
    
    98
    +                        baseline_value = float(baseline_match.group(2))
    
    99
    +                        benchmark_value = float(benchmark_match.group(2))
    
    71 100
     
    
    72 101
                             # Calculate the percentage difference
    
    73 102
                             percentage_diff =  ((baseline_value - benchmark_value) / baseline_value) * 100
    
    74 103
     
    
    75 104
                             if baseline_value > benchmark_value:
    
    76
    -                            html_file.write('<tr><td>{}</td><td>{:.2f}\tus/op</td><td style="background-color: green;">{:.2f}\tus/op</td><td>{:.2f}%</td></tr>\n'.format(baseline_match.group(1), baseline_value, benchmark_value, percentage_diff))
    
    105
    +                            html_file.write('<tr><td class="col1">{}</td><td class="lowlight">{:.2f}</td><td class="highlight">{:.2f}</td><td>{:.2f}</td></tr>\n'.format(baseline_match.group(1), baseline_value, benchmark_value, percentage_diff))
    
    77 106
                             else:
    
    78
    -                            html_file.write('<tr><td>{}</td><td>{:.2f}\tus/op</td><td>{:.2f}\tus/op</td><td>{:.2f}%</td></tr>\n'.format(baseline_match.group(1), baseline_value, benchmark_value, percentage_diff))
    
    107
    +                            html_file.write('<tr><td class="col1">{}</td><td class="highlight">{:.2f}</td><td class="lowlight">{:.2f}</td><td>{:.2f}</td></tr>\n'.format(baseline_match.group(1), baseline_value, benchmark_value, percentage_diff))
    
    79 108
     
    
    80 109
                 html_file.write('</table><br/>\n')
    
    81 110
     
    


  • reply via email to

    [Prev in Thread] Current Thread [Next in Thread]