ftbench demo with seperate makefile

This commit is contained in:
goksu 2023-05-25 13:46:16 +03:00
parent 562f348192
commit 9dd15018c2
No known key found for this signature in database
10 changed files with 1713 additions and 0 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@ src/dlg/dlg.c
subprojects/*
!subprojects/*.wrap
/tests/data/*
.DS_Store

View File

@ -0,0 +1,40 @@
# Variables
FTBENCH_SRC = ftbench.c
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)))
# Default target
all: $(FTBENCH_BIN)
# Build ftbench
$(FTBENCH_BIN): $(FTBENCH_SRC)
gcc $(FTBENCH_FLAGS) $(FTBENCH_SRC) -o $(FTBENCH_BIN)
# Create directories for baselines and benchmarks
baselines/ benchmarks/:
mkdir -p $@
# Create a baseline
.PHONY: baseline
baseline: $(FTBENCH_BIN) baselines/
$(foreach font, $(FONTS), \
./$(FTBENCH_BIN) $(font) > baselines/$(notdir $(font)).txt; \
)
# Benchmark and compare to baseline
.PHONY: benchmark
benchmark: $(FTBENCH_BIN) benchmarks/
$(foreach font, $(FONTS), \
./$(FTBENCH_BIN) $(font) > benchmarks/$(notdir $(font)).txt; \
)
$(foreach font, $(FONTS), \
diff baselines/$(notdir $(font)).txt benchmarks/$(notdir $(font)).txt; \
)
.PHONY: clean
clean:
rm -f $(FTBENCH_BIN)
rm -rf baselines/ benchmarks/

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,15 @@
#!/bin/bash
# Define the Unicode range
unicodes="U+0021-007E"
# Loop over all .ttf files in the current directory
for fontfile in *.ttf
do
# Generate the output filename
output="${fontfile%.ttf}_subset.ttf"
# Run the pyftsubset command
pyftsubset "$fontfile" --unicodes=$unicodes --output-file="$output"
done

1613
src/tools/ftbench/ftbench.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,44 @@
/*
* This is a cheap replacement for getopt() because that routine is not
* available on some platforms and behaves differently on other platforms.
*
* This code is hereby expressly placed in the public domain.
* mleisher@crl.nmsu.edu (Mark Leisher)
* 10 October 1997
*/
#ifndef MLGETOPT_H_
#define MLGETOPT_H_
#ifdef VMS
#include <stdio.h>
#define getopt local_getopt
#define optind local_optind
#define opterr local_opterr
#define optarg local_optarg
#endif
#ifdef __cplusplus
extern "C" {
#endif
extern int opterr;
extern int optind;
extern char* optarg;
extern int getopt(
#ifdef __STDC__
int argc,
char* const* argv,
const char* pattern
#endif
);
#ifdef __cplusplus
}
#endif
#endif /* MLGETOPT_H_ */
/* End */