Ahmet Göksu pushed to branch GSoC-2023-Ahmet at FreeType / FreeType
Commits:
-
b0712e9a
by goksu at 2023-06-01T16:17:36+03:00
-
0e87ae09
by goksu at 2023-06-11T12:10:31+03:00
-
93b8d393
by goksu at 2023-06-12T14:06:45+03:00
-
f95a2c82
by goksu at 2023-06-12T17:44:04+03:00
13 changed files:
- .gitignore
- builds/freetype.mk
- + builds/testing.mk
- − src/tools/ftbench/Makefile
- src/tools/ftbench/fonts/Arial_subset.ttf → src/tools/ftbench/fonts/deactivated/Arial_subset.ttf
- src/tools/ftbench/fonts/Roboto_subset.ttf → src/tools/ftbench/fonts/deactivated/Roboto_subset.ttf
- src/tools/ftbench/fonts/Tahoma_subset.ttf → src/tools/ftbench/fonts/deactivated/Tahoma_subset.ttf
- src/tools/ftbench/fonts/TimesNewRoman_subset.ttf → src/tools/ftbench/fonts/deactivated/TimesNewRoman_subset.ttf
- − src/tools/ftbench/fonts/sub.sh
- src/tools/ftbench/ftbench.c
- + src/tools/ftbench/src/benchmark.html
- src/tools/ftbench/mlgetopt.h → src/tools/ftbench/src/mlgetopt.h
- + src/tools/ftbench/src/tohtml.py
Changes:
... | ... | @@ -5,4 +5,3 @@ src/dlg/dlg.c |
5 | 5 | subprojects/*
|
6 | 6 | !subprojects/*.wrap
|
7 | 7 | /tests/data/* |
8 | -.DS_Store |
... | ... | @@ -162,6 +162,11 @@ FT_COMPILE := $(CC) $(ANSIFLAGS) $(INCLUDE_FLAGS) $(FT_CFLAGS) |
162 | 162 | include $(TOP_DIR)/builds/exports.mk
|
163 | 163 | |
164 | 164 | |
165 | +# Include the `testing' rules file.
|
|
166 | +#
|
|
167 | +include $(TOP_DIR)/builds/testing.mk
|
|
168 | + |
|
169 | + |
|
165 | 170 | # Initialize the list of objects.
|
166 | 171 | #
|
167 | 172 | OBJECTS_LIST :=
|
1 | +# Variables
|
|
2 | +FTBENCH_DIR = $(TOP_DIR)/src/tools/ftbench
|
|
3 | +FTBENCH_SRC = $(FTBENCH_DIR)/ftbench.c
|
|
4 | +FTBENCH_BIN = $(FTBENCH_DIR)/bench
|
|
5 | +FTBENCH_FLAGS = $(shell pkg-config --cflags freetype2) -lfreetype
|
|
6 | +FONTS = $(wildcard $(FTBENCH_DIR)/fonts/*.ttf)
|
|
7 | +BASELINES = $(addprefix $(FTBENCH_DIR)/baselines/, $(notdir $(FONTS:.ttf=.txt)))
|
|
8 | +BENCHMARKS = $(addprefix $(FTBENCH_DIR)/benchmarks/, $(notdir $(FONTS:.ttf=.txt)))
|
|
9 | +PYTHON = python3
|
|
10 | +HTMLCREATOR = $(FTBENCH_DIR)/src/tohtml.py
|
|
11 | +HTMLFILE = $(TOP_DIR)/benchmark.html
|
|
12 | + |
|
13 | +# Create directories for baselines and benchmarks
|
|
14 | +$(FTBENCH_DIR)/baselines/ $(FTBENCH_DIR)/benchmarks/:
|
|
15 | + @mkdir -p $@
|
|
16 | + |
|
17 | +# Build ftbench
|
|
18 | +$(FTBENCH_BIN): $(FTBENCH_SRC)
|
|
19 | + @echo "Building ftbench..."
|
|
20 | + @gcc $(FTBENCH_FLAGS) $< -o $@
|
|
21 | + |
|
22 | +# Create a baseline
|
|
23 | +.PHONY: baseline
|
|
24 | +baseline: $(FTBENCH_BIN) $(FTBENCH_DIR)/baselines/
|
|
25 | + @echo "Creating baseline..."
|
|
26 | + @$(foreach font, $(FONTS), \
|
|
27 | + $(FTBENCH_BIN) $(font) > $(FTBENCH_DIR)/baselines/$(notdir $(font:.ttf=.txt)); \
|
|
28 | + )
|
|
29 | + @echo "Baseline created."
|
|
30 | + |
|
31 | +# Benchmark and compare to baseline
|
|
32 | +.PHONY: benchmark
|
|
33 | +benchmark: $(FTBENCH_BIN) $(FTBENCH_DIR)/benchmarks/
|
|
34 | + @echo "Creating benchmark..."
|
|
35 | + @$(foreach font, $(FONTS), \
|
|
36 | + $(FTBENCH_BIN) $(font) > $(FTBENCH_DIR)/benchmarks/$(notdir $(font:.ttf=.txt)); \
|
|
37 | + )
|
|
38 | + @$(PYTHON) $(HTMLCREATOR) > $(HTMLFILE)
|
|
39 | + @echo "Benchmark created."
|
|
40 | + |
|
41 | +.PHONY: clean-benchmark
|
|
42 | +clean-benchmark:
|
|
43 | + @echo "Cleaning..."
|
|
44 | + @rm -f $(FTBENCH_BIN)
|
|
45 | + @rm -rf $(FTBENCH_DIR)/baselines/ $(FTBENCH_DIR)/benchmarks/ $(HTMLFILE)
|
|
46 | + @echo "Cleaned." |
1 | -# Variables
|
|
2 | -FTBENCH_SRC = ftbench.c
|
|
3 | -FTBENCH_BIN = bench.out
|
|
4 | -FTBENCH_FLAGS = $(shell pkg-config --cflags freetype2) -lfreetype
|
|
5 | -FONTS = $(wildcard fonts/*.ttf)
|
|
6 | -BASELINES = $(addprefix baselines/, $(notdir $(FONTS)))
|
|
7 | -BENCHMARKS = $(addprefix benchmarks/, $(notdir $(FONTS)))
|
|
8 | - |
|
9 | -# Default target
|
|
10 | -all: $(FTBENCH_BIN)
|
|
11 | - |
|
12 | -# Build ftbench
|
|
13 | -$(FTBENCH_BIN): $(FTBENCH_SRC)
|
|
14 | - gcc $(FTBENCH_FLAGS) $(FTBENCH_SRC) -o $(FTBENCH_BIN)
|
|
15 | - |
|
16 | -# Create directories for baselines and benchmarks
|
|
17 | -baselines/ benchmarks/:
|
|
18 | - mkdir -p $@
|
|
19 | - |
|
20 | -# Create a baseline
|
|
21 | -.PHONY: baseline
|
|
22 | -baseline: $(FTBENCH_BIN) baselines/
|
|
23 | - $(foreach font, $(FONTS), \
|
|
24 | - ./$(FTBENCH_BIN) $(font) > baselines/$(notdir $(font)).txt; \
|
|
25 | - )
|
|
26 | - |
|
27 | -# Benchmark and compare to baseline
|
|
28 | -.PHONY: benchmark
|
|
29 | -benchmark: $(FTBENCH_BIN) benchmarks/
|
|
30 | - $(foreach font, $(FONTS), \
|
|
31 | - ./$(FTBENCH_BIN) $(font) > benchmarks/$(notdir $(font)).txt; \
|
|
32 | - )
|
|
33 | - $(foreach font, $(FONTS), \
|
|
34 | - diff baselines/$(notdir $(font)).txt benchmarks/$(notdir $(font)).txt; \
|
|
35 | - )
|
|
36 | - |
|
37 | -.PHONY: clean
|
|
38 | -clean:
|
|
39 | - rm -f $(FTBENCH_BIN)
|
|
40 | - rm -rf baselines/ benchmarks/ |
1 | -#!/bin/bash
|
|
2 | - |
|
3 | -# Define the Unicode range
|
|
4 | -unicodes="U+0021-007E"
|
|
5 | - |
|
6 | -# Loop over all .ttf files in the current directory
|
|
7 | -for fontfile in *.ttf
|
|
8 | -do
|
|
9 | - # Generate the output filename
|
|
10 | - output="${fontfile%.ttf}_subset.ttf"
|
|
11 | - |
|
12 | - # Run the pyftsubset command
|
|
13 | - pyftsubset "$fontfile" --unicodes=$unicodes --output-file="$output"
|
|
14 | -done
|
|
15 | - |
... | ... | @@ -40,7 +40,7 @@ |
40 | 40 | #ifdef UNIX
|
41 | 41 | #include <unistd.h>
|
42 | 42 | #else
|
43 | -#include "mlgetopt.h"
|
|
43 | +#include "src/mlgetopt.h"
|
|
44 | 44 | #endif
|
45 | 45 | |
46 | 46 | #ifdef _WIN32
|
1 | +<html>
|
|
2 | +<head>
|
|
3 | +<title>Benchmark Results</title>
|
|
4 | +</head>
|
|
5 | +<body>
|
|
6 | +<h1>Benchmark Results</h1> |
1 | +import os
|
|
2 | +import re
|
|
3 | + |
|
4 | +# Create the HTML file
|
|
5 | +with open('../../../../benchmark.html', 'w') as f:
|
|
6 | + f.write('<html>\n')
|
|
7 | + f.write('<head>\n')
|
|
8 | + f.write('<title>Benchmark Results</title>\n')
|
|
9 | + f.write('</head>\n')
|
|
10 | + f.write('<body>\n')
|
|
11 | + f.write('<h1>Benchmark Results</h1>\n')
|
|
12 | + |
|
13 | + # Traverse through the 'baselines' directory
|
|
14 | + for filename in os.listdir('../baselines'):
|
|
15 | + baseline_filepath = os.path.join('../baselines', filename)
|
|
16 | + benchmark_filepath = os.path.join('../benchmarks', filename)
|
|
17 | + |
|
18 | + # Process the baseline file
|
|
19 | + with open(baseline_filepath, 'r') as baseline_file:
|
|
20 | + baseline_lines = baseline_file.readlines()
|
|
21 | + |
|
22 | + # Process the benchmark file
|
|
23 | + with open(benchmark_filepath, 'r') as benchmark_file:
|
|
24 | + benchmark_lines = benchmark_file.readlines()
|
|
25 | + |
|
26 | + f.write(f'<h2>Results for {filename}</h2>\n')
|
|
27 | + f.write('<table border="1">\n')
|
|
28 | + f.write('<tr><th>Test</th><th>Baseline</th><th>Benchmark</th></tr>\n')
|
|
29 | + |
|
30 | + # For each line in the baseline and benchmark files
|
|
31 | + for baseline_line, benchmark_line in zip(baseline_lines, benchmark_lines):
|
|
32 | + # If the line starts with a space, it's a test result line
|
|
33 | + if baseline_line.startswith(' '):
|
|
34 | + # Extract the test name, the time per operation, and the number of operations done
|
|
35 | + baseline_match = re.match(r' (\w+(\s\(\w+\))?)\s+(\d+\.\d+)\s', baseline_line)
|
|
36 | + benchmark_match = re.match(r' (\w+(\s\(\w+\))?)\s+(\d+\.\d+)\s', benchmark_line)
|
|
37 | + |
|
38 | + # If the line could be parsed
|
|
39 | + if baseline_match and benchmark_match:
|
|
40 | + # Check which value is higher
|
|
41 | + baseline_value = float(baseline_match.group(3))
|
|
42 | + benchmark_value = float(benchmark_match.group(3))
|
|
43 | + |
|
44 | + # Write the test result to the HTML file
|
|
45 | + if baseline_value > benchmark_value:
|
|
46 | + f.write(f'<tr><td>{baseline_match.group(1)}</td><td style="background-color: green;">{baseline_match.group(3)}</td><td>{benchmark_match.group(3)}</td></tr>\n')
|
|
47 | + else:
|
|
48 | + f.write(f'<tr><td>{baseline_match.group(1)}</td><td>{baseline_match.group(3)}</td><td style="background-color: green;">{benchmark_match.group(3)}</td></tr>\n')
|
|
49 | + |
|
50 | + f.write('</table>\n')
|
|
51 | + |
|
52 | + f.write('</body>\n')
|
|
53 | + f.write('</html>\n') |