安裝 fio 源碼後即可使用 fio_generate_plots。
Fio Git URL
# you can execute "git clone git://git.kernel.dk/fio.git"
git://git.kernel.dk/fio.git
Script Path
fio/tools/
該工具預設繪制 Latency、IOPS、slat、clat、BandWidth 等 5 種曲線,預設是 将相鄰點連線(lines)。
- 隻繪制 IOPS 的曲線
# 可以修改 腳本 fio_generate_plots,如下:
#plot "I/O Latency" lat "Time (msec)" 1000
plot "I/O Operations Per Second" iops "IOPS" 1
#plot "I/O Submission Latency" slat "Time (μsec)" 1
#plot "I/O Completion Latency" clat "Time (msec)" 1000
#plot "I/O Bandwidth" bw "Throughput (KB/s)" 1
- 隻需要标記資料點
# 可将 lines 修改為 point。
PLOT_LINE=$PLOT_LINE"'$x' using (\$1/1000):(\$2/$SCALE) title \"Queue depth $DEPTH\" with point ls $i"
- 修改完成後,重新編譯安裝 fio 即可使用
make clean && make -j8 && make install -j8
- 如何使用 fio_generate_plots
關于 gnuplot 的使用
安裝 gnuplot
# install for CentOS
yum install -y gnuplot
繪圖
# 輸出圖檔格式:
set term jpeg size 1280,720
set title 'plot for sin'
set output 'sin.jpeg'
# plot 語句
p [0:100] [-1:1] "sin.log" u 1:2 title "sin" w lp lt 1 lw 2 lc "green" pt 4 ps 2
- set term jpeg size 1280,720
- 設定輸出圖檔大小為 1280 * 720,輸出格式為 *.jpeg
- set title ‘plot for sin’
- 設定圖檔标題為 plot for sin
- set output ‘sin.jpeg’
- 設定輸出圖檔名稱為 sin.jpeg
上述 plot 語句使用了簡寫指令,
# 實際上相當于:
plot [0:100] [-1:1] "sin.log" using 1:2 title "sin" with linepoint linetype 1 linewidth 2 linecolor "green" pointtype 4 pointsize 2
接下來,分析下每個參數具體是什麼意思:
- p [0:100] [-1:1]
- p 就是 plot,後面的兩項分别為圖檔顯示的 x 軸、y 軸的坐标範圍。
- “sin.log” u 1:2
- 用 “sin.log” 中的第 1、2 列資料畫圖,其中第 1 列資料作為橫坐标,第 2 列資料作為縱坐标。
- title “sin”
- 命名這條曲線為 “sin”,此處的名稱為該曲線在圖例中顯示的名稱,并不是圖檔的标題。
- w lp
-
即 with linepoint ,标記資料點并将資料點連線。with 後的屬性參數有多個選擇,對應不同的作圖方式(style)。
在圖形界面的終端中輸入 help with 或者 help style 就可以查到可供選擇的 style 參數。常用的作圖方式參數及對應含義如下表所示:
-
style 參數 | 簡寫指令 | 含義 |
---|---|---|
line | l | 将相鄰的資料點連線 |
point | p | 将每一個資料點用一個符号标記 |
linepoint | lp | 将每一個資料點用一個符号标記,并将相鄰資料點連線 |
impulses | i | 将每一個資料點畫一條垂直線至 x 軸 |
dots | d | 将每一個資料點繪制一個細點 |
steps | st | 分别用一條垂直線及水準線 來連接配接兩點,并形成台階狀圖形 |
errorbars | e | 對每一點坐标值(x, y),繪制一條由(x, ylow) 至(x, yhigh) 的線段。并線上段兩端做上标記 |
boxes | boxes | 以 x 坐标為中心 繪制 柱狀圖 |
boxerrorbars | boxerrorbars | 相當于 errorbars 與 boxes |
- lt 1
- 即 linetype 1 ,規定了連線的類型,-1 對應黑虛線,0 對應黑虛線,大于 0 的整數對應不同顔色的實線。
- 1 為紫色,2 為綠色,3 為藍色,4 為橙色、5 為黃色、6 為深藍色、7 為紅色、8 為黑色,大于 8 的數字對應的顔色與其對 8 取餘對應的顔色相同。
- lw 2
- 即 linewidth 2 ,規定了線的寬度,數字越大,線條越寬。
- lc “green”
-
即 linecolor “green” ,規定了線的顔色。除了之前利用 lt 來規定線的顔色之外,也可以通過這個語句單獨設定線的顔色,可供選擇的顔色比 lt 中的多。
在圖形界面的終端中輸入 show colorname 就可以檢視不同的 RGB 對應的名稱。
-
- pt 4
- 即 pointtype 4,規定了标記點的類型。不同數字對應的标記點如下:
數字 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
标記符号 | 無 | + | × | ❈ | □ | ■ | ○ | ● | △ | ▲ | ▽ | ▼ | ◇ | ◆ |
- ps 2
- 即 pointsize 2,規定了标志的大小,數字越大,标志越大。标志 的顔色 和 線 的顔色相同。