mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Benchmarked memory models for Toy_Array, read more
The results can be found in 'tests/benchmarks/array_allocation/results.md' The results are disappointing, as 'malloc()' is simply faster in every possible situation compared to my custom arena allocator.
This commit is contained in:
104
tests/benchmarks/array_allocation/makefile
Normal file
104
tests/benchmarks/array_allocation/makefile
Normal file
@@ -0,0 +1,104 @@
|
||||
#compiler settings
|
||||
CC=gcc
|
||||
CFLAGS+=-std=c17 -g -Wall -Werror -Wextra -Wpedantic -Wformat=2
|
||||
LIBS+=-lm
|
||||
LDFLAGS+=
|
||||
|
||||
ifeq ($(shell uname),Linux)
|
||||
LDFLAGS=-Wl,--gc-sections
|
||||
else ifeq ($(OS),Windows_NT)
|
||||
LDFLAGS=-Wl,--gc-sections
|
||||
else ifeq ($(shell uname),Darwin)
|
||||
LDFLAGS=-Wl,-dead_strip
|
||||
else
|
||||
@echo "LDFLAGS set failed - what platform is this?"
|
||||
endif
|
||||
|
||||
#patched incl
|
||||
TOY_SOURCEDIR=source
|
||||
|
||||
#directories
|
||||
TEST_ROOTDIR=../../..
|
||||
TEST_SOURCEDIR=$(TEST_ROOTDIR)/$(TOY_SOURCEDIR)
|
||||
TEST_CASESDIR=.
|
||||
|
||||
TEST_OUTDIR=out
|
||||
TEST_OBJDIR=obj
|
||||
|
||||
#file names
|
||||
TEST_SOURCEFILES=$(wildcard $(TEST_SOURCEDIR)/*.c)
|
||||
TEST_CASESFILES=$(wildcard $(TEST_CASESDIR)/bench_*.c)
|
||||
|
||||
#build the object files, compile the test cases, and run
|
||||
all: clean
|
||||
$(MAKE) build-source
|
||||
$(MAKE) build-cases
|
||||
$(MAKE) build-link
|
||||
$(MAKE) build-run
|
||||
|
||||
#targets for each step
|
||||
.PHONY: build-source
|
||||
build-source: $(TEST_OUTDIR) $(TEST_OBJDIR) $(addprefix $(TEST_OBJDIR)/,$(notdir $(TEST_SOURCEFILES:.c=.o)))
|
||||
|
||||
.PHONY: build-cases
|
||||
build-cases: $(TEST_OUTDIR) $(TEST_OBJDIR) $(addprefix $(TEST_OBJDIR)/,$(notdir $(TEST_CASESFILES:.c=.o)))
|
||||
|
||||
.PHONY: build-link
|
||||
build-link: $(TEST_OUTDIR) $(TEST_OBJDIR) $(addprefix $(TEST_OUTDIR)/,$(notdir $(TEST_CASESFILES:%.c=%.exe)))
|
||||
|
||||
.PHONY: build-run
|
||||
build-run: $(addprefix $(TEST_OUTDIR)/,$(notdir $(TEST_CASESFILES:%.c=%.exe))) $(addprefix $(TEST_OUTDIR)/,$(notdir $(TEST_CASESFILES:%.c=%.run)))
|
||||
|
||||
#compilation steps
|
||||
$(TEST_OBJDIR)/%.o: $(TEST_SOURCEDIR)/%.c
|
||||
$(CC) -c -o $@ $< $(addprefix -I,$(TEST_SOURCEDIR)) $(CFLAGS) -fdata-sections -ffunction-sections
|
||||
|
||||
$(TEST_OBJDIR)/%.o: $(TEST_CASESDIR)/%.c
|
||||
$(CC) -c -o $@ $< $(addprefix -I,$(TEST_SOURCEDIR) $(TEST_CASESDIR)) $(CFLAGS) -fdata-sections -ffunction-sections
|
||||
|
||||
$(TEST_OUTDIR)/%.exe: $(TEST_OBJDIR)/%.o
|
||||
@$(CC) -o $@ $< $(addprefix $(TEST_OBJDIR)/,$(notdir $(TEST_SOURCEFILES:.c=.o))) $(CFLAGS) $(LIBS) $(LDFLAGS)
|
||||
strip $@
|
||||
|
||||
.PRECIOUS: $(TEST_OUTDIR)/%.run
|
||||
$(TEST_OUTDIR)/%.run: $(TEST_OUTDIR)/%.exe
|
||||
@/usr/bin/time --format "User System\n%U %E" $<
|
||||
|
||||
#util targets
|
||||
$(TEST_OUTDIR):
|
||||
mkdir $(TEST_OUTDIR)
|
||||
|
||||
$(TEST_OBJDIR):
|
||||
mkdir $(TEST_OBJDIR)
|
||||
|
||||
#util commands
|
||||
.PHONY: clean
|
||||
clean:
|
||||
ifeq ($(shell uname),Linux)
|
||||
find . -type f -name '*.o' -delete
|
||||
find . -type f -name '*.a' -delete
|
||||
find . -type f -name '*.exe' -delete
|
||||
find . -type f -name '*.dll' -delete
|
||||
find . -type f -name '*.lib' -delete
|
||||
find . -type f -name '*.so' -delete
|
||||
find . -type f -name '*.dylib' -delete
|
||||
find . -type d -name 'out' -delete
|
||||
find . -type d -name 'obj' -delete
|
||||
else ifeq ($(OS),Windows_NT)
|
||||
$(RM) *.o *.a *.exe *.dll *.lib *.so *.dylib
|
||||
$(RM) out
|
||||
$(RM) obj
|
||||
else ifeq ($(shell uname),Darwin)
|
||||
find . -type f -name '*.o' -delete
|
||||
find . -type f -name '*.a' -delete
|
||||
find . -type f -name '*.exe' -delete
|
||||
find . -type f -name '*.dll' -delete
|
||||
find . -type f -name '*.lib' -delete
|
||||
find . -type f -name '*.so' -delete
|
||||
find . -type f -name '*.dylib' -delete
|
||||
find . -type d -name 'out' -delete
|
||||
find . -type d -name 'obj' -delete
|
||||
else
|
||||
@echo "Deletion failed - what platform is this?"
|
||||
endif
|
||||
|
||||
Reference in New Issue
Block a user