forked from sysprog21/phonebook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
85 lines (70 loc) · 2.39 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
CC ?= gcc
CFLAGS_common ?= -Wall -std=gnu99
CFLAGS_orig = -O0
CFLAGS_opt = -O0
EXEC = phonebook_orig phonebook_opt phonebook_strcp
all: $(EXEC)
SRCS_common = main.c
phonebook_orig: $(SRCS_common) phonebook_orig.c phonebook_orig.h
$(CC) $(CFLAGS_common) $(CFLAGS_orig) \
-DIMPL="\"$@.h\"" -o $@ \
$(SRCS_common) $@.c
phonebook_opt: $(SRCS_common) phonebook_opt.c phonebook_opt.h
$(CC) $(CFLAGS_common) $(CFLAGS_opt) \
-DIMPL="\"$@.h\"" -o $@ \
$(SRCS_common) $@.c
phonebook_strcp: $(SRCS_common) phonebook_strcp.c phonebook_strcp.h
$(CC) $(CFLAGS_common) $(CFLAGS_opt) \
-DIMPL="\"$@.h\"" -o $@ \
$(SRCS_common) $@.c
run: $(EXEC)
echo 3 | sudo tee /proc/sys/vm/drop_caches
watch -d -t "./phonebook_orig && echo 3 | sudo tee /proc/sys/vm/drop_caches"
cache-test: $(EXEC)
echo 1 | sudo tee /proc/sys/vm/drop_caches # Drop the cache
perf stat --repeat 100 \
-e cache-misses,cache-references,instructions,cycles \
./phonebook_orig > /dev/null
echo 1 | sudo tee /proc/sys/vm/drop_caches # Drop the cache
perf stat --repeat 100 \
-e cache-misses,cache-references,instructions,cycles \
./phonebook_opt > /dev/null
echo 1 | sudo tee /proc/sys/vm/drop_caches # Drop the cache
perf stat --repeat 100 \
-e cache-misses,cache-references,instructions,cycles \
./phonebook_strcp > /dev/null
cache-record: $(EXEC)
echo 1 | sudo tee /proc/sys/vm/drop_caches # Drop the cache
3>perf_orig.log perf stat --repeat 100 \
-e cache-misses \
-x cache-misses \
--log-fd 3 \
./phonebook_orig > /dev/null
echo 1 | sudo tee /proc/sys/vm/drop_caches # Drop the cache
3>perf_opt.log perf stat --repeat 100 \
-e cache-misses \
-x cache-misses \
--log-fd 3 \
./phonebook_opt > /dev/null
echo 1 | sudo tee /proc/sys/vm/drop_caches # Drop the cache
3>perf_strcp.log perf stat --repeat 100 \
-e cache-misses \
-x cache-misses \
--log-fd 3 \
./phonebook_strcp > /dev/null
output.txt: cache-test calculate
./calculate
cache.txt: cache-record calculate_cache
./calculate_cache
plot: output.txt cache.txt
gnuplot scripts/runtime.gp
gnuplot scripts/cache.gp
calculate: calculate.c
$(CC) $(CFLAGS_common) $^ -o $@
calculate_cache: calculate_cache.c
$(CC) $(CFLAGS_common) $^ -o $@
.PHONY: clean
clean:
$(RM) $(EXEC) *.o perf.* \
calculate orig.txt opt.txt opt_strCompress.txt output.txt runtime.png \
calculate_cache perf_orig.log perf_opt.log perf_strcp.log output_cache.txt cache.png