# 2020q3 Homework3 (dict) contributed by < `joey3639570` > ###### tags: `進階電腦系統理論與實作` ### 20201003 紀錄 `make test` ``` Performance counter stats for './test_common --bench CPY s Tai' (100 runs): 644,6378 cache-misses # 59.385 % of all cache refs ( +- 0.14% ) 1085,5241 cache-references ( +- 0.16% ) 5,8774,0970 instructions # 0.99 insn per cycle ( +- 0.02% ) 5,9494,2583 cycles ( +- 0.12% ) 0.19405 +- 0.00109 seconds time elapsed ( +- 0.56% ) ``` ``` Performance counter stats for './test_common --bench REF s Tai' (100 runs): 640,4946 cache-misses # 58.638 % of all cache refs ( +- 0.29% ) 1092,2802 cache-references ( +- 0.25% ) 5,5421,2901 instructions # 0.93 insn per cycle ( +- 0.00% ) 5,9316,0349 cycles ( +- 0.34% ) 0.192271 +- 0.000661 seconds time elapsed ( +- 0.34% ) ``` `make bench` ``` COPY mechanism test_common => choice: find words matching prefix (at least 1 char): Tai - searched prefix in 0.000165 sec REFERENCE mechanism test_common => choice: find words matching prefix (at least 1 char): Tai - searched prefix in 0.000212 sec ``` ## 視覺化 ternary search tree (TST) + bloom filter 的效能表現並分析 ## CPY V.S. REF >- copy 機制 (CPY): 傳入 tst_ins_del 的字串地址所表示的值隨時會被覆寫,因此 eqkid 需要 malloc 新空間將其 copy 存起來; >- reference 機制 (REF): 傳進來的字串地址所表示的值一直屬於該字串,以此可將其當作 reference 直接存起來,不用透過 malloc 新空間。 ## Memory Pool ```c= if (CPYmask) { /* memory pool */ malloc(poolsize * sizeof(char)); Top = pool; } ```