Skip to content
This repository was archived by the owner on Aug 19, 2021. It is now read-only.

Commit ba0c701

Browse files
committed
Added rudimentary profiling
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
1 parent 5ac2216 commit ba0c701

File tree

3 files changed

+375
-10
lines changed

3 files changed

+375
-10
lines changed

.travis.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
11
script:
2+
# Strict compilation of library
23
- CFLAGS='-pedantic -Werror' make
4+
5+
# Runtime tests
36
- make test
7+
8+
# Relative profiling with current master
9+
- if ( git clone https://github.com/geky/events tests/master &&
10+
make -s -C tests/master prof | tee tests/results.txt ) ;
11+
then
12+
cat tests/results.txt | make prof ;
13+
else
14+
make prof ;
15+
fi

Makefile

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ OBJ := $(SRC:.c=.o)
99
DEP := $(SRC:.c=.d)
1010
ASM := $(SRC:.c=.s)
1111

12-
TESTS = tests/tests
13-
TSRC += $(wildcard tests/*.c)
14-
TOBJ := $(TSRC:.c=.o)
15-
TDEP := $(TSRC:.c=.d)
16-
1712
ifdef DEBUG
1813
CFLAGS += -O0 -g3 -DMU_DEBUG
1914
CFLAGS += -fkeep-inline-functions
@@ -33,9 +28,13 @@ LFLAGS += -lpthread
3328

3429
all: $(TARGET)
3530

36-
test: $(TOBJ) $(OBJ)
37-
$(CC) $(CFLAGS) $^ $(LFLAGS) -o $(TESTS)
38-
$(TESTS)
31+
test: tests/tests.o $(OBJ)
32+
$(CC) $(CFLAGS) $^ $(LFLAGS) -o tests/tests
33+
tests/tests
34+
35+
prof: tests/prof.o $(OBJ)
36+
$(CC) $(CFLAGS) $^ $(LFLAGS) -o tests/prof
37+
tests/prof
3938

4039
asm: $(ASM)
4140

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

5655
clean:
5756
rm -f $(TARGET)
58-
rm -f $(TESTS)
59-
rm -f $(TOBJ) $(TDEP)
57+
rm -f tests/tests tests/tests.o tests/tests.d
58+
rm -f tests/prof tests/prof.o tests/prof.d
6059
rm -f $(OBJ)
6160
rm -f $(DEP)
6261
rm -f $(ASM)

0 commit comments

Comments
 (0)