contributed by <kevinbird61
>
$@
、$<
%
main: main.o foo1.o foo2.o
${CC} main.o foo1.o ${CFLAGS} ${INC} ${LIB} -o $@
%.o: %.c target.h
${CC} $< ${CFLAGS} ${INC} ${LIB} -lpthread -c
舉個例子來看,在編譯時,target main裡頭需要main.o及foo1.o,此時便到%.o該行去,這時的%便是main,而$<
就是main.c;而換成foo1.o時,此行的%便成為foo1了,而$<
此時就是foo1.c
plot [:][:0.150]'output.txt'
using 2:xtic(1) with histogram title 'original', \
'' using ($0-0.06):(0):2 with labels title ' '
A:110
B:000001
C:00001
D:01111
E:100
F:111110
G:11110
H:10101
I:0001
J:11111110
K:001110
L:1110
M:01110
N:0101
O:0100
P:10100
Q:11111111
R:0010
S:0110
T:1011
U:00110
V:0000000
W:0000001
X:11111101
Y:001111
Z:11111100
Huffman compression主要的壓縮方式為:
原始
Performance counter stats for './phonebook_orig' (100 runs):
942,621 cache-misses # 85.133 % of all cache refs ( +- 0.91% )
1,107,232 cache-references ( +- 1.01% )
260,742,129 instructions # 1.40 insns per cycle ( +- 0.02% )
185,766,505 cycles ( +- 0.52% )
0.058256961 seconds time elapsed ( +- 2.26% )
Performance counter stats for './phonebook_opt' (100 runs):
120,558 cache-misses # 47.111 % of all cache refs ( +- 1.78% )
255,901 cache-references ( +- 2.12% )
244,779,086 instructions # 1.74 insns per cycle ( +- 0.02% )
140,485,801 cycles ( +- 1.56% )
0.044147859 seconds time elapsed ( +- 1.82% )
Performance counter stats for './phonebook_strcp' (100 runs):
81,212 cache-misses # 49.898 % of all cache refs ( +- 1.82% )
162,754 cache-references ( +- 2.58% )
773,720,487 instructions # 2.14 insns per cycle ( +- 0.09% )
361,496,589 cycles ( +- 1.82% )
0.111428579 seconds time elapsed ( +- 1.83% )
「程式輸出的文字訊息」請勿使用圖片表示,請改由文字貼上課程助教
Step 4:之後findName(),把輸入的Name同樣以Huffman compression過後比對
增加繪製cache-misses的script來檢視每次運行產生的cache-misses
順便看到perf輸出於stderr,非stdout,所以除了在command時加上2>&1之外,還可以用perf stat -o <fileName>來輸出,並可再加上 -x <file separator>來處理我要輸出的特定字串資訊,這樣就不需要對直接輸出的格式做負責的處理。