Try   HackMD

進階電腦系統理論與實作 (Fall 2016)A03: compute-pi


Reviewed by <eeuserp>

  • Makefile 中的 plot 區塊 是先 %s 再 %u , 代表會先輸出 system time 然後再輸出 user time 到 time.txt , 圖表呈現的 kernel mode 與 user mode 時間長條圖 與 time.txt 的資料剛好相反。.gp檔裡相關指令必須修改。
  • 將 plot2 的輸出結果 smooth 並沒有從計算圓周率的演算法去著手,從.gp檔改變指令消除較為突出的數據造成 smooth 後的圖失去了原圖的資料特徵,失去了實驗的意義。那些突出的分析結果並沒有消失,只是沒有在圖表上出現。

自己做一個 make plot

長條圖

time 是linux內建的指令,他的輸出格式可以自己選擇,而且其實time還可以輸出其他的資訊,像是process在執行期間總共被 swap out 出 main memory 的次數,但是如果在command 直接打time的話,它所提供的所有option就會無法使用,若要使用的話就要打/usr/bin/time輸出格式可以參考這個網址

因為使用gnuplot的話需要把資料先建成文字檔案當成輸入,如果要把time指令的輸出資料匯入到文字檔的話可以打成

{ /usr/bin/time -f 'baseline %S %U' ./time_test_baseline ; } 2> time.txt

-f是標示要使用特定的字串格式輸入。
最後把這些動作寫進Makefile裡就行了

指令:

make plot

執行結果

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

折線圖

首先要學習Makefile的迴圈要怎麼寫,

for i in `seq 100 5000 25000`; do \
	printf "%d," $$i;\
	./benchmark_clock_gettime $$i; \
done > result_clock_gettime.csv	

seq後面接著的數字第一個代表i的起始數字,接著是指i在每次迴圈之後要加多少,再來接著的是i結束的數字。
製作自己的gp來話折線圖可以參考[這個網站](http://blog.csdn.net/baigoocn/article/details/38417505)
畫出圖之後我們會發現圖的震盪會很大,所以為了讓圖容易看出趨勢,我們會使用平滑,gnuplot內建的平滑方式有很多種,可以參考這個網站,但我們要知道不是每一個都可以用,因為有一些平滑方式會把資料做排序,這些都不是我們要的,最後我選擇 bezier 這個方法。

指令:

make plot2

執行結

Smooth前:

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Smooth後:
Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

參考網址:

http://stackoverflow.com/questions/13356628/is-there-a-way-to-redirect-time-output-to-file-in-linux
http://www.cyberciti.biz/faq/unix-linux-time-command-examples-usage-syntax/