forked from embedded2015/phonebook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
50 lines (37 loc) · 1.41 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
CC ?= gcc
CFLAGS_common ?= -O0 -Wall -std=gnu99
SRCS_common = main.c
SRCS_FILES = $(wildcard *.c)
EXEC = $(basename $(notdir $(filter-out $(SRCS_common), $(SRCS_FILES))))
all: $(EXEC)
cache_ptr:
@sudo sh -c "echo 0 > /proc/sys/kernel/kptr_restrict"
clear_cache:
@echo "echo 1 > /proc/sys/vm/drop_caches" | sudo sh
phonebook_%: $(SRCS_common) phonebook_%.c phonebook_%.h
$(CC) $(CFLAGS_common) -DIMPL="\"$@.h\"" -o $@ \
$(SRCS_common) $@.c
run_%: phonebook_%
watch -d -t ./$<
stat_%: phonebook_% cache_ptr clear_cache
@perf stat \
-e cache-misses,cache-references,L1-dcache-load-misses,L1-dcache-store-misses,L1-dcache-prefetch-misses,L1-icache-load-misses \
./$<
record_%: phonebook_% cache_ptr clear_cache
@perf record -F 15000 \
-e cache-misses,cache-references,L1-dcache-load-misses,L1-dcache-store-misses,L1-dcache-prefetch-misses,L1-icache-load-misses \
./$< && perf report
shuf_%:
shuf -o ./dictionary/$*RAND.txt ./dictionary/$*.txt
run_many_%: phonebook_%
@for i in $(shell seq 1 200); \
do ./$< | grep sec | awk '{count++} count % 2 == 0 {print $$6 >> "append_$*.txt"} count % 2 == 1 {print $$6 >> "findName_$*.txt"}'; \
done
dcache_%: stat_%
@for i in $(shell seq 1 200); \
do make stat_$* 2>&1 | grep L1-dcache-load-misses | awk '{gsub(",","",$$1); print $$1 >> "dcache_$*.txt"}'; \
done
clean:
$(RM) $(EXEC) *.o perf.*
style:
@astyle --style=kr --indent=spaces=4 --indent-switches --suffix=none *.[ch]