mirror of https://github.com/freetype/freetype
parent
0e87ae09a6
commit
93b8d39394
|
@ -1,12 +1,10 @@
|
|||
# Variables
|
||||
FTBENCH_SRC = ftbench.c
|
||||
FTBENCH_BIN = bench
|
||||
FTBENCH_BIN = bench.out
|
||||
FTBENCH_FLAGS = $(shell pkg-config --cflags freetype2) -lfreetype
|
||||
FONTS = $(wildcard fonts/*.ttf)
|
||||
BASELINES = $(addprefix baselines/, $(notdir $(FONTS)))
|
||||
BENCHMARKS = $(addprefix benchmarks/, $(notdir $(FONTS)))
|
||||
PYTHON = python3
|
||||
HTMLCREATOR = src/tohtml.py
|
||||
|
||||
# Default target
|
||||
all: $(FTBENCH_BIN)
|
||||
|
@ -14,7 +12,6 @@ all: $(FTBENCH_BIN)
|
|||
# Build ftbench
|
||||
$(FTBENCH_BIN): $(FTBENCH_SRC)
|
||||
gcc $(FTBENCH_FLAGS) $(FTBENCH_SRC) -o $(FTBENCH_BIN)
|
||||
@echo "Built."
|
||||
|
||||
# Create directories for baselines and benchmarks
|
||||
baselines/ benchmarks/:
|
||||
|
@ -26,7 +23,6 @@ baseline: $(FTBENCH_BIN) baselines/
|
|||
$(foreach font, $(FONTS), \
|
||||
./$(FTBENCH_BIN) $(font) > baselines/$(notdir $(font)).txt; \
|
||||
)
|
||||
@echo "baseline created"
|
||||
|
||||
# Benchmark and compare to baseline
|
||||
.PHONY: benchmark
|
||||
|
@ -34,16 +30,11 @@ benchmark: $(FTBENCH_BIN) benchmarks/
|
|||
$(foreach font, $(FONTS), \
|
||||
./$(FTBENCH_BIN) $(font) > benchmarks/$(notdir $(font)).txt; \
|
||||
)
|
||||
$(PYTHON) $(HTMLCREATOR)
|
||||
@echo "benchmark created."
|
||||
|
||||
.PHONY: page
|
||||
page: benchmarks/ baselines/
|
||||
$(PYTHON) $(HTMLCREATOR)
|
||||
@echo "HTML page of the benchmark created."
|
||||
$(foreach font, $(FONTS), \
|
||||
diff baselines/$(notdir $(font)).txt benchmarks/$(notdir $(font)).txt; \
|
||||
)
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -f $(FTBENCH_BIN)
|
||||
rm -rf baselines/ benchmarks/ *.html
|
||||
@echo "cleaned."
|
||||
rm -rf baselines/ benchmarks/
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#ifdef UNIX
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#include "src/mlgetopt.h"
|
||||
#include "mlgetopt.h"
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
import os
|
||||
import re
|
||||
|
||||
# Create the HTML file
|
||||
with open('benchmark_results.html', 'w') as f:
|
||||
f.write('<html>\n')
|
||||
f.write('<head>\n')
|
||||
f.write('<title>Benchmark Results</title>\n')
|
||||
f.write('</head>\n')
|
||||
f.write('<body>\n')
|
||||
f.write('<h1>Benchmark Results</h1>\n')
|
||||
|
||||
# Traverse through the 'baselines' directory
|
||||
for filename in os.listdir('baselines'):
|
||||
baseline_filepath = os.path.join('baselines', filename)
|
||||
benchmark_filepath = os.path.join('benchmarks', filename)
|
||||
|
||||
# Process the baseline file
|
||||
with open(baseline_filepath, 'r') as baseline_file:
|
||||
baseline_lines = baseline_file.readlines()
|
||||
|
||||
# Process the benchmark file
|
||||
with open(benchmark_filepath, 'r') as benchmark_file:
|
||||
benchmark_lines = benchmark_file.readlines()
|
||||
|
||||
f.write(f'<h2>Results for {filename}</h2>\n')
|
||||
f.write('<table border="1">\n')
|
||||
f.write('<tr><th>Test</th><th>Baseline</th><th>Current</th></tr>\n')
|
||||
|
||||
# For each line in the baseline and benchmark files
|
||||
for baseline_line, benchmark_line in zip(baseline_lines, benchmark_lines):
|
||||
# If the line starts with a space, it's a test result line
|
||||
if baseline_line.startswith(' '):
|
||||
# Extract the test name, the time per operation, and the number of operations done
|
||||
baseline_match = re.match(r' (\w+(\s\(\w+\))?)\s+(\d+\.\d+)\s', baseline_line)
|
||||
benchmark_match = re.match(r' (\w+(\s\(\w+\))?)\s+(\d+\.\d+)\s', benchmark_line)
|
||||
|
||||
# If the line could be parsed
|
||||
if baseline_match and benchmark_match:
|
||||
# Check which value is higher
|
||||
baseline_value = float(baseline_match.group(3))
|
||||
benchmark_value = float(benchmark_match.group(3))
|
||||
|
||||
# Write the test result to the HTML file
|
||||
if baseline_value > benchmark_value:
|
||||
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')
|
||||
else:
|
||||
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')
|
||||
|
||||
f.write('</table>\n')
|
||||
|
||||
f.write('</body>\n')
|
||||
f.write('</html>\n')
|
Loading…
Reference in New Issue