Skip to content

Commit

Permalink
Added rudimentary profiling
Browse files Browse the repository at this point in the history
Simple cycle-measuring based profiling setup in tests/prof.c
- uses rdtsc instruction for cycle-level measurement
- averages each test repeatedly over PROF_INTERVAL cycles
- test best result of PROF_RUNS runs to throw out unexpected interrupts
- percentage comparison with previous versions for tangible results

To profile a single instance:
make prof

To compare two runs (this will show rough measurement error):
make prof > results.txt && cat results.txt | make prof
  • Loading branch information
geky committed Jul 14, 2016
1 parent 5ac2216 commit ba0c701
Show file tree
Hide file tree
Showing 3 changed files with 375 additions and 10 deletions.
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
script:
# Strict compilation of library
- CFLAGS='-pedantic -Werror' make

# Runtime tests
- make test

# Relative profiling with current master
- if ( git clone https://github.com/geky/events tests/master &&
make -s -C tests/master prof | tee tests/results.txt ) ;
then
cat tests/results.txt | make prof ;
else
make prof ;
fi
19 changes: 9 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ OBJ := $(SRC:.c=.o)
DEP := $(SRC:.c=.d)
ASM := $(SRC:.c=.s)

TESTS = tests/tests
TSRC += $(wildcard tests/*.c)
TOBJ := $(TSRC:.c=.o)
TDEP := $(TSRC:.c=.d)

ifdef DEBUG
CFLAGS += -O0 -g3 -DMU_DEBUG
CFLAGS += -fkeep-inline-functions
Expand All @@ -33,9 +28,13 @@ LFLAGS += -lpthread

all: $(TARGET)

test: $(TOBJ) $(OBJ)
$(CC) $(CFLAGS) $^ $(LFLAGS) -o $(TESTS)
$(TESTS)
test: tests/tests.o $(OBJ)
$(CC) $(CFLAGS) $^ $(LFLAGS) -o tests/tests
tests/tests

prof: tests/prof.o $(OBJ)
$(CC) $(CFLAGS) $^ $(LFLAGS) -o tests/prof
tests/prof

asm: $(ASM)

Expand All @@ -55,8 +54,8 @@ size: $(OBJ)

clean:
rm -f $(TARGET)
rm -f $(TESTS)
rm -f $(TOBJ) $(TDEP)
rm -f tests/tests tests/tests.o tests/tests.d
rm -f tests/prof tests/prof.o tests/prof.d
rm -f $(OBJ)
rm -f $(DEP)
rm -f $(ASM)
Loading

0 comments on commit ba0c701

Please sign in to comment.